Towards Better Understanding of Contrastive Sentence Representation Learning: A Unified Paradigm for Gradient

Mingxin Li, Richong Zhang, Zhijie Nie

Abstract

Contrastive self-supervised learning (SSL) has become the dominant approach for Sentence Representation Learning (SRL), yet the failure of non-contrastive methods in this domain has remained poorly understood. This paper identifies a unified gradient paradigm shared by effective contrastive objectives, defined by three critical components: Gradient Dissipation, Weight, and Ratio. We demonstrate that by manually injecting these components into the gradients of "ineffective" non-contrastive objectives like Barlow Twins and VICReg, we can bridge the performance gap and achieve state-of-the-art results in semantic textual similarity tasks.

Introduction

In SRL, the objective is to map sentences into a vector space where semantic proximity is reflected by geometric distance. While contrastive SSL—which explicitly separates positive pairs from negative samples—excels at this, non-contrastive methods (e.g., Barlow Twins, VICReg) often fail at Semantic Textual Similarity (STS) tasks despite their success in other domains. This research investigates the underlying gradient dynamics to explain this discrepancy and proposes a method to unify these disparate approaches.

The Unified Gradient Paradigm

By analyzing the gradients of successful contrastive losses such as InfoNCE, ArcCon, and MET, the authors discovered a shared mathematical structure:

$$\frac{\partial \mathcal{L}_i}{\partial h_i} = GD(\cdot) \sum_{j \neq i} W(\cdot)(h'_j - R(\cdot)h'_i)$$

This paradigm is governed by three "knobs":

  1. Gradient Dissipation (GD): A safety valve that reduces gradient magnitude as samples become sufficiently separated, preventing over-fitting on "easy" examples.
  2. Weight (W): A mechanism that ensures "hard negatives" (dissimilar sentences currently close in vector space) dominate the optimization process.
  3. Ratio (R): A term controlling the relative strength of the "pull" toward positive samples versus the "push" away from negatives.

Key Insights and Ideas

The Importance of Ranking and Hard Negatives

Non-contrastive methods typically fail at STS because they lack the fine-grained "push" provided by the Weight component. Without it, models struggle to learn the subtle semantic distinctions required for ranking tasks. Furthermore, the authors proved via Lemma 1 (The Ratio Condition) that for an optimization step to effectively move an anchor toward its positive sample, the Ratio must satisfy a specific lower bound, a condition naturally met by contrastive losses but often violated by non-contrastive ones.

The Safety Valve Effect

In STS tasks, similarity is a continuous scale (0-5) rather than a binary classification. Without Gradient Dissipation, models continue to optimize even when samples are well-separated, which can destroy the nuanced structure of the representation space.

Effect of Gradient Dissipation on cosine similarity distribution.

Key Results

By modifying the gradients of non-contrastive objectives to include GD, W, and R, the researchers transformed previously underperforming methods into top-tier models.

  • Barlow Twins ($L^B$): Spearman correlation on STS-B (BERT-base) improved from 65.60 to 78.34.
  • VICReg ($L^V$): Improved from 65.53 to 78.24 on the same benchmark.
  • Alignment & Uniformity: When modified, these metrics achieved an average STS score of 78.40, outperforming standard InfoNCE (76.25).
Performance comparison of original (ori) and modified (mod) objectives across BERT and RoBERTa backbones.

These improvements were consistent across both BERT and RoBERTa backbones and did not compromise performance on general transfer tasks (TR), suggesting that the specific mathematical form of a loss function is less important than its resulting gradient dynamics.

Conclusion

This work provides a roadmap for understanding and improving SSL objectives in NLP. By focusing on gradient components rather than loss functions alone, researchers can "fix" ineffective objectives and achieve state-of-the-art performance. Future work may explore how these gradient dynamics interact with different model architectures and whether this paradigm extends to other modalities like Computer Vision.

Summary updated

BibTeX
@inproceedings{li2024towards,
  author = {Mingxin Li and Richong Zhang and Zhijie Nie},
  title = {{Towards Better Understanding of Contrastive Sentence Representation Learning: A Unified Paradigm for Gradient}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.780},
}
Figure