Abstract
Few-shot relation classification (RC) requires models to identify semantic relationships between entities with minimal labeled data. While transformer-based models are effective, they often underutilize the diverse information encoded within their internal layers. This paper presents MultiRep, a framework that extracts and aligns multiple internal representations—including [CLS], [MASK], and entity markers—using a novel contrastive learning objective. By enforcing consistency across these distinct "views" in a single forward pass, MultiRep achieves state-of-the-art results on the FewRel benchmark, demonstrating superior efficiency and accuracy in data-scarce scenarios.
Introduction
Relation Classification (RC) is a fundamental task in information extraction, focused on identifying the semantic link between two entities within a sentence. For example, in the sentence "Paris is the capital of France," a model must identify the capital of relation between "Paris" and "France." While Large Language Models (LLMs) have advanced the field, performing this task in a "few-shot" setting—where only a handful of labeled examples are available for new relation types—remains a significant challenge.
Existing RC models typically rely on a single representation, such as "entity markers" (special tokens surrounding the entities), to capture the relationship. However, this approach ignores the wealth of untapped information distributed across other parts of the model's architecture, such as the [CLS] token or the [MASK] token used in prompting. The MultiRep framework addresses this inefficiency by extracting and aligning multiple internal representations to create a more robust and discriminative feature space.
Methodology
MultiRep introduces a multi-view approach to representation learning that maximizes the information extracted from a single transformer forward pass.
1. Multi-View Representation Extraction
Instead of selecting a single vector, MultiRep extracts four distinct representations from a BERT-based architecture:
- Average Pooling: The mean of all token vectors in the sentence.
- [CLS] Token: The standard global sentence-level summary.
- Entity Markers: Vectors derived from the start tokens of the two target entities.
- [MASK] Token: A representation generated using a "prompting" style, where the model predicts the relation at a masked position.
2. Contrastive Learning Objectives
The core innovation of MultiRep lies in its dual contrastive loss functions:
- Representation-Representation Contrastive Loss ($L_{RCL}$): This loss treats different representations of the same sentence as positive pairs and representations of different sentences as negative pairs. This forces the model to ensure that the [CLS], [MASK], and entity markers converge on the same underlying relationship while retaining their unique, complementary nuances.
- Instance-Relation Description Contrastive Loss ($L_{RDCL}$): When textual descriptions of relations are available (e.g., "spouse: a person joined in marriage"), MultiRep aligns the sentence representations with these semantic descriptions, further grounding the model's understanding.
3. Classification via Prototypical Networks
For the final classification, the model employs a Prototypical Network approach. It calculates a "prototype" (an average vector) for each class in the support set and assigns query sentences to the nearest prototype based on distance in the embedding space.
Experimental Results
The model was evaluated on FewRel, the standard benchmark for few-shot relation classification, which includes 100 relation types derived from Wikipedia. MultiRep was tested across various N-way K-shot configurations.
Performance Highlights
MultiRep consistently outperformed strong baselines, including HCRP and SimpleFSRE:
- Without Relation Descriptions: In 5-way 1-shot tasks, MultiRep achieved 89.20% accuracy, surpassing the previous state-of-the-art BERT-Pair (88.32%).
- With Relation Descriptions: Performance improved to 94.18% in 5-way 1-shot tasks, setting a new high-water mark for the benchmark.
- Ablation Study: Removing the $L_{RCL}$ loss led to a significant performance decline, confirming that the alignment of multiple internal views is critical to the model's success.
Discussion and Insights
MultiRep's success stems from its efficiency via single-pass extraction. Unlike many contrastive learning methods that require multiple forward passes with data augmentations (like cropping or masking), MultiRep generates its "multiple views" from a single pass. This makes it significantly more resource-efficient than competing methods.
Furthermore, the model demonstrates high adaptability. It remains highly competitive even when relation descriptions are unavailable, yet it can seamlessly integrate semantic metadata to boost performance when it is provided. Qualitative analysis via t-SNE visualizations indicates that MultiRep produces much tighter and more distinct clusters for similar relations (e.g., distinguishing between "mother" and "child") compared to standard models.
Conclusion and Future Work
MultiRep demonstrates that the internal representations of transformer models contain complementary information that can be effectively harnessed through contrastive alignment. While the current implementation results in a larger embedding vector due to concatenation, the gains in accuracy and few-shot robustness are substantial.
Future research will explore the application of multi-view alignment to larger generative models (such as Llama or GPT-4) and investigate whether these techniques can help mitigate hallucinations in generative relation extraction tasks. Additionally, the authors aim to test the framework's generalizability across other NLP tasks, such as named entity recognition and summarization.
Summary updated