Introduction
In Natural Language Processing, sentence representation learning maps sentences into mathematical vectors where semantic similarity corresponds to vector proximity. While contrastive learning models like SimCSE have set high standards, they often rely on a binary "positive vs. negative" logic. This approach treats all non-positive samples in a batch as equally negative, failing to capture the nuanced semantic relationships required for fine-grained ranking tasks. RankCSE addresses this by integrating "Learning to Rank" principles into the unsupervised contrastive framework.
Methodology
RankCSE enhances the standard contrastive setup with two sophisticated ranking objectives designed to capture fine-grained semantic nuances:
- Ranking Consistency: The model generates two slightly different representations of the same sentence using different dropout masks. It then enforces that both "views" rank all other sentences in the batch in a consistent order of similarity. This is achieved by minimizing the Jensen-Shannon (JS) divergence between the two ranking distributions.
- Ranking Distillation: To provide a "ground truth" for ranking, RankCSE utilizes a pre-trained teacher model (e.g., SimCSE). The student model learns to mimic the teacher's list-wise ranking order using established ranking losses like ListNet or ListMLE.
- Multi-Teacher Approach: The framework can leverage multiple teachers (e.g., BERT-base and BERT-large) to provide a more robust signal, often allowing the student to generalize better than any single teacher.
Experimental Setup
The model is trained in an entirely unsupervised manner using 1 million randomly sampled sentences from English Wikipedia. Evaluation is conducted on the Semantic Textual Similarity (STS) datasets (STS12-16, STS-B, and SICK-R), where performance is measured by the Spearman's correlation between model similarity scores and human annotations. Additionally, the embeddings are tested on seven Transfer (TR) tasks, including sentiment analysis and linguistic property detection, to assess versatility.
Results and Analysis
RankCSE achieves significant improvements over previous state-of-the-art models across both BERT and RoBERTa architectures. On BERT-base, RankCSE improved the average Spearman’s correlation by 4.11% over SimCSE. Notably, the RankCSE-BERT-base model outperforms the much larger SimCSE-BERT-large by nearly 2%.
Beyond standard similarity benchmarks, RankCSE excels in ranking-specific metrics. As shown in Figure 2, RankCSE consistently produces more accurate orderings than SimCSE and DiffCSE, as measured by Kendall’s Correlation Coefficient (KCC) and Normalized Discounted Cumulative Gain (NDCG).
Furthermore, RankCSE helps mitigate the "anisotropy" problem, where embeddings occupy a narrow cone in the vector space. By producing a more uniform distribution of vectors, the model creates a more discriminative and better-aligned representation space.
Conclusion
RankCSE demonstrates that treating in-batch negatives as a ranked list rather than a flat pool of negatives provides a significantly richer training signal for unsupervised sentence embeddings. While the approach introduces additional computational costs during training due to teacher pseudo-labeling and list-wise losses, the resulting gains in both similarity and ranking accuracy represent a new state-of-the-art for unsupervised representations. Future work may explore scaling these ranking principles to supervised data and larger foundation models.
Summary updated