TL;DR
SharpReCL is a new framework designed to fix a major flaw in Supervised Contrastive Learning (SCL): its extreme sensitivity to imbalanced data. By leveraging learned class prototypes to generate synthetic "hard" samples via mixup, the model creates a balanced training environment that consistently outperforms standard baselines and even beats Large Language Models (LLMs) like GPT-3.5 and Llama 3 on specialized text classification tasks.
What Problem Does This Paper Address?
While Supervised Contrastive Learning (SCL) has become a powerful tool for text classification—pushing similar samples together and pulling different ones apart—it has a "hidden" weakness. In real-world datasets, some classes have thousands of examples while others have only a handful.
The authors mathematically demonstrate that SCL actually amplifies this imbalance. Because SCL operates on pairs of samples, an imbalance ratio of $ir$ in the raw data becomes $ir^2$ during contrastive training. If one class is 10 times larger than another, it effectively has 100 times more influence during the contrastive phase. This leads to "gradient vanishing" for minority classes, where the model simply stops learning their unique features. Furthermore, most existing models treat the classification branch (using standard Cross-Entropy) and the contrastive branch as separate silos, missing out on mutual guidance.
Methods
The authors propose SharpReCL (Simple-Sampling and Hard-Mixup with Prototypes to Rebalance Contrastive Learning). The architecture consists of two interacting branches:
- Balanced Classification Branch: Instead of standard Cross-Entropy, it uses Logit Compensation, which adjusts the classification boundary based on class frequency. Crucially, the weights of this classifier are treated as Class Prototypes—vector representations of the "ideal" member of each class.
- Balanced Contrastive Learning Branch: This branch uses the prototypes to bridge the gap between classification and contrastive tasks through two main techniques:
- Simple-Sampling: The model injects the class prototypes directly into every training batch. This ensures that even the rarest minority class is represented in every single gradient update.
- Hard-Mixup: The model identifies "hard" samples—positives that are far from their class prototype and negatives that are dangerously close. It then uses Mixup (linear interpolation) to synthesize new, difficult training pairs. This creates a balanced, challenging target set that forces the encoder to learn more robust features.
Datasets
The model was evaluated on six diverse datasets:
- Highly Imbalanced: R52 (Reuters news) and Ohsumed (Medical titles).
- Balanced/Standard: TREC (Questions), DBLP (Computer science titles), Biomedical (Topic labeling), and CR (Customer reviews).
- Note: For the balanced datasets, the authors manually induced imbalance (ratios of 10, 20, and 50) to test the model's robustness.
Key Insights and Ideas
- The $ir^2$ Problem: The most significant "aha" moment is the realization that SCL's pair-based nature makes data imbalance quadratically worse. This explains why standard SCL often fails on long-tailed real-world data.
- Prototypes as Anchors: By using the classifier's own weights as prototypes, the model ensures the two branches are mathematically aligned. The classification branch tells the contrastive branch what a "good" class member looks like.
- Harder is Better: Simply oversampling minority classes isn't enough. By specifically synthesizing hard examples through mixup, the model avoids the "easy sample" trap where gradients become too small to be useful (gradient vanishing).
- Domain Specificity Beats Scale: The fact that a fine-tuned BERT-based model can beat Llama 3 on medical (Ohsumed) and biomedical data suggests that specialized architectural fixes for data distribution can be more effective than simply increasing model parameters.
Key Results
SharpReCL achieved state-of-the-art results across the board:
- Vs. Baselines: It consistently outperformed other imbalanced learning methods (like BERT+Focal Loss) and contrastive methods (like SimCSE and DualCL). On the R52 dataset, it achieved a Macro-F1 of 84.83%, significantly higher than the next best non-LLM baseline.
- Vs. LLMs: In the Ohsumed dataset (ir=50), SharpReCL reached a Macro-F1 of 60.82%, outperforming GPT-3.5 (43.83%) and Llama 3-8B (58.59%).
- Clustering Quality: t-SNE visualizations show that SharpReCL produces much tighter, more distinct class clusters compared to other contrastive methods, even under high imbalance.
Limitations and Future Work
The authors acknowledge a few areas for improvement:
- Backbone Dependency: The performance is still tied to the underlying transformer (e.g., BERT). While it beats LLMs in specific settings, it doesn't replace their general-purpose reasoning.
- Hyperparameter Sensitivity: While the model is robust to the contrastive weight $\mu$, the temperature $\tau$ still requires careful tuning to maintain F1 scores (as seen in Figure 3).
- Future Directions: The authors suggest exploring these prototype-based rebalancing techniques in multi-modal settings (e.g., image-text) where data imbalance is equally prevalent.
Summary updated