Supervised Contrastive Learning Approach for Contextual Ranking

Abhijit Anand, Jurek Leonhardt, Koustav Rudra, Avishek Anand

Introduction

Modern information retrieval (IR) has been transformed by contextual ranking models based on architectures like BERT, RoBERTa, and DistilBERT. These models excel at capturing semantic nuances but are notoriously "data-hungry." Due to their over-parameterized nature—often containing hundreds of millions of parameters—they are highly susceptible to overfitting when trained on smaller, specialized datasets common in fields like law, medicine, or finance.

While Data Augmentation (DA) is a standard technique to mitigate data scarcity in other domains, its application in document ranking has been inconsistent. Traditional training objectives, such as pointwise or pairwise losses, often struggle with the noise introduced by synthetic data, sometimes leading to performance degradation. This paper introduces RankingSCL, a supervised contrastive learning framework designed to leverage query-specific data augmentation effectively, even in low-data regimes.

Methodology: The RankingSCL Framework

The proposed approach addresses the limitations of standard ranking losses through a two-pronged strategy: query-specific data augmentation and a supervised contrastive learning (SCL) objective.

Query-Specific Data Augmentation

Rather than treating a document as a monolithic entity, the authors generate "augmented positives" by extracting the most relevant segments of a document for a given query. Three selection strategies were evaluated:

  1. BM25: Selecting sentences based on traditional lexical term-matching.
  2. GloVe: Identifying sentences with high semantic similarity using word embeddings.
  3. Sampling: Randomly selecting sentences to provide structural variety.

Supervised Contrastive Learning (SCL)

The core innovation is the application of SCL to the ranking task. Unlike standard losses that evaluate documents in isolation or simple pairs, SCL considers the relationships between all documents within a training batch.

Figure 1: Comparison of standard pairwise loss versus the proposed Supervised Contrastive Learning (SCL) loss.

As illustrated in Figure 1, the SCL loss forces the model to cluster representations of "relevant" segments (both original and augmented) closer together in the embedding space while simultaneously pushing non-relevant documents further away. The final training objective is a linear combination of the standard ranking loss and this new SCL loss, allowing the model to benefit from contrastive signals without losing the primary ranking signal.

Experimental Evaluation

The researchers benchmarked RankingSCL across several diverse datasets, including TREC-DL (2019/2020), Robust04, and specialized datasets like FiQA (finance) and SciFact (science). To test the model's robustness to data scarcity, they evaluated performance across varying training sizes, ranging from 1,000 to 100,000 instances.

Analysis of Results

The experiments yielded several critical insights into the behavior of contrastive learning in IR:

The Primacy of the Loss Function

A significant finding was that the choice of loss function is more critical than the augmentation strategy itself. When using standard Cross-Entropy (CE) loss, adding augmented data often resulted in worse performance due to the noise in synthetic examples. In contrast, the SCL objective proved robust to this noise, consistently turning augmented data into performance gains.

Figure 2: Performance improvement of RankingSCL (SCL) vs. standard Cross-Entropy (CE) across different training set sizes.

Diminishing Returns and Model Efficiency

As shown in Figure 2, the marginal utility of RankingSCL is highest when training data is most scarce. For instance, on the 10k instance subset of TREC-DL, BERT achieved a 12.9% improvement in Reciprocal Rank (RR). However, as the dataset size approached 100,000 instances, the gap between SCL and standard training narrowed, as the model eventually encountered enough original data to generalize effectively.

Furthermore, SCL proved particularly beneficial for smaller models like DistilBERT. By providing a richer training signal, SCL allows these efficient, compressed models to approach the performance levels of their larger counterparts, making them more viable for production environments with limited computational budgets.

Conclusion

RankingSCL provides a robust framework for training contextual rankers in data-constrained environments. By combining query-specific augmentation with a contrastive loss, the method overcomes the noise sensitivity of traditional objectives. While challenges remain regarding input length constraints and fine-tuning stability on extremely small sets, RankingSCL represents a significant step toward making state-of-the-art IR models accessible for specialized domains where massive labeled datasets are unavailable.

Summary updated

BibTeX
@inproceedings{anand2022supervised,
  author = {Abhijit Anand and Jurek Leonhardt and Koustav Rudra and Avishek Anand},
  title = {{Supervised Contrastive Learning Approach for Contextual Ranking}},
  booktitle = {ICTIR},
  year = {2022},
  doi = {10.1145/3539813.3545139},
}
Figure