Abstract
Natural language inference (NLI) is an increasingly important task for natural language understanding, which requires one to infer the relationship between the sentence pair (premise and hypothesis). Many recent works have used contrastive learning by incorporating the relationship of the sentence pair from NLI datasets to learn sentence representation. However, these methods only focus on comparisons with sentence-level representations. In this paper, we propose a Pair-level Supervised Contrastive Learning approach (PairSCL). We adopt a cross attention module to learn the joint representations of the sentence pairs. A contrastive learning objective is designed to distinguish the varied classes of sentence pairs by pulling those in one class together and pushing apart the pairs in other classes. We evaluate PairSCL on two public datasets of NLI where the accuracy of PairSCL outperforms other methods by 2.1% on average. Furthermore, our method outperforms the previous state-of-the-art method on seven transfer tasks of text classification.
Introduction
Natural Language Inference (NLI) requires a model to determine the logical relationship between a premise and a hypothesis, typically categorizing them as entailment, contradiction, or neutral. While contrastive learning techniques like SimCSE have significantly improved language model performance, they often rely on sentence-level representations. These methods treat individual sentence pairs as unique instances, often pushing apart different pairs that actually share the same logical class. This paper introduces PairSCL to address this "false negative" problem by shifting the focus to class-aware, pair-level comparisons.
Methodology
The PairSCL framework consists of three primary components designed to capture deep relational semantics between sentences:
- Text Encoder: The system utilizes pre-trained models such as BERT or RoBERTa to extract initial token embeddings for both the premise and the hypothesis.
- Cross Attention Module: Unlike models that encode sentences in isolation, PairSCL computes a token-level co-attention matrix. It extracts heuristic matching features—including concatenation, difference, and element-wise products—to construct a joint pair-level representation.
- Joint Training Objective: The model is optimized using a dual loss function. A standard Cross-Entropy (CE) Loss handles classification, while a Supervised Contrastive Learning (SCL) Loss uses class labels to pull representations of the same NLI class together and push different classes apart.
Results
PairSCL was evaluated on the SNLI and MultiNLI benchmarks, as well as seven transfer tasks for text classification. The model demonstrated significant improvements over existing baselines.
- NLI Benchmarks: PairSCL-RoBERTa achieved a state-of-the-art accuracy of 93.2% on SNLI and 92.7%/92.3% on MultiNLI (matched/mismatched). On average, the BERT-based variant outperformed previous state-of-the-art BERT models by 2.1% on SNLI.
- Transfer Tasks: The representations generalized effectively across seven downstream tasks (including MR, SST-2, and MRPC), with PairSCL-RoBERTa reaching an average accuracy of 89.23%, surpassing the SimCSE-RoBERTa baseline.
Discussion
Ablation studies highlight that the Cross Attention Module is the most critical component, as its removal leads to the largest performance drop (1.6%). This suggests that token-level interaction is essential for understanding complex logical relationships. Furthermore, the SCL loss successfully mitigates the "false negative" issue inherent in standard contrastive learning by grouping pairs based on abstract logical categories rather than surface-level sentence similarity.
Conclusion
PairSCL effectively leverages pair-level interactions and supervised contrastive learning to set new benchmarks in NLI. While the cross-encoder architecture provides superior accuracy, it introduces higher computational costs during inference compared to dual-encoder models like SBERT. Future research may focus on distilling these high-quality pair-level representations into more efficient architectures for large-scale applications.
Summary updated