Introduction
Contrastive learning (CL) has emerged as a powerful paradigm for representation learning, typically by encouraging similarity between different "views" of the same instance. While successful in unsupervised settings, its application to supervised text classification often remains disjointed. Standard Supervised Contrastive Learning (SCL) focuses on clustering examples of the same class but typically requires a separate training phase for the final linear classifier. This decoupling is suboptimal, as it fails to learn features and decision boundaries simultaneously.
Dual Contrastive Learning (DualCL) addresses this by integrating labels directly into the representation space. By treating labels as "augmented views" of the data, DualCL learns both input features and classifier parameters within a unified framework, significantly enhancing performance, particularly in low-resource scenarios.
Methodology: Label-Aware Data Augmentation
The core of DualCL is the concept of Label-Aware Data Augmentation. Instead of processing raw text, the model prepends all potential class labels (e.g., "positive", "negative") to the input sequence. This allows a pretrained model like BERT to generate two distinct types of representations for every input $x$:
- Feature Representation ($z$): Derived from the
[CLS]token, representing the input text's content. - Classifier Representation ($\theta$): Derived from the prepended label tokens, acting as a "one-example classifier" tailored to that specific input.
The Dual Contrastive Loss
The model is optimized using a Dual Contrastive Loss, which consists of two complementary components:
- $L_z$: This loss pulls the feature vector $z$ toward the classifier weights of its ground-truth class while pushing it away from incorrect class weights.
- $L_\theta$: This loss pulls the classifier weights of the correct class toward the features of other examples belonging to the same class.
This joint optimization, combined with a modified Cross-Entropy loss, ensures that the generated classifier $\theta$ is intrinsically effective at categorizing the feature $z$. Theoretically, minimizing this dual loss is equivalent to maximizing the mutual information between inputs and labels.
Experimental Results
The authors evaluated DualCL across five benchmark datasets (SST-2, SUBJ, TREC, PC, and CR) using BERT and RoBERTa backbones. DualCL consistently outperformed standard Cross-Entropy (CE) and existing SCL methods.
Performance in Low-Resource Settings
The most significant advantages of DualCL are observed when training data is scarce. In few-shot scenarios, the model's ability to leverage label semantics provides a robust prior for classification. For instance, on the SST-2 dataset with only 5 training samples per class, DualCL achieved an 8.5% accuracy improvement over the standard baseline.
Visual analysis using t-SNE further confirms that DualCL produces tighter, more discriminative clusters in the representation space compared to traditional supervised methods. Attention visualizations also indicate that the model focuses more effectively on sentiment-bearing words rather than neutral context.
Conclusion and Future Work
Dual Contrastive Learning redefines supervised representation learning by unifying feature and classifier training through label-aware augmentation. By treating labels as part of the feature space, it achieves state-of-the-art results and exceptional sample efficiency. Future research may explore extending this "dual" representation approach to other modalities, such as image or graph classification, and investigating strategies to mitigate the reliance on semantically meaningful label names.
Summary updated