RankCSE: Unsupervised Sentence Representations Learning via Learning to Rank

Jiduan Liu, Jiahao Liu, Qifan Wang, Jingang Wang, Wei Wu, Yunsen Xian, Dongyan Zhao, Kai Chen, Rui Yan

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:

  1. 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.
  2. 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.
  3. 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.
The RankCSE framework illustrating the interaction between Teacher and Student models through Ranking Consistency and Ranking Distillation.

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).

Performance comparison of RankCSE against SimCSE and DiffCSE on ranking metrics KCC and 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

BibTeX
@inproceedings{liu2023rankcse,
  author = {Jiduan Liu and Jiahao Liu and Qifan Wang and Jingang Wang and Wei Wu and Yunsen Xian and Dongyan Zhao and Kai Chen and Rui Yan},
  title = {{RankCSE: Unsupervised Sentence Representations Learning via Learning to Rank}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.771},
}
Figure