ESimCSE: Enhanced Sample Building Method for Contrastive Learning of Unsupervised Sentence Embedding

Xing Wu, Chaochen Gao, Liangjun Zang, Jizhong Han, Zhongyuan Wang, Songlin Hu

Abstract

ESimCSE (Enhanced SimCSE) is a novel framework designed to improve unsupervised sentence embeddings by addressing two primary limitations of the popular SimCSE model: length bias and the scarcity of negative samples. By implementing a "word repetition" strategy to diversify sentence lengths and a "momentum contrast" queue to broaden the pool of negative pairs, ESimCSE achieves a significant 2.02% average improvement in Spearman correlation over SimCSE across standard semantic textual similarity (STS) benchmarks.

Introduction

Unsupervised representation learning for sentences has recently been dominated by SimCSE, which utilizes a "dropout-as-augmentation" strategy. This approach generates positive pairs by passing the same sentence through a Transformer encoder twice with different dropout masks. However, this method introduces a subtle length bias. Since Transformers utilize positional embeddings, the model can distinguish sentence length. In SimCSE, positive pairs always share identical lengths, while negative pairs typically do not. This leads the model to learn length as a shortcut for similarity rather than focusing on semantic content. Furthermore, the effectiveness of contrastive learning is often constrained by the number of negative examples, which is limited by GPU memory in standard batch-based training.

Methods

ESimCSE introduces two key enhancements to the contrastive learning pipeline: Word Repetition and Momentum Contrast.

The ESimCSE architecture featuring word repetition for positive pairs and a momentum encoder with a queue for negative pairs.

Word Repetition

To mitigate length bias, ESimCSE employs a "word repetition" strategy for positive pair augmentation. By randomly duplicating sub-words (e.g., "I like like this apple apple"), the framework varies the sequence length and positional embeddings without altering the sentence's semantics. This forces the model to recognize semantic equivalence despite structural differences. Unlike random insertion or deletion, word repetition is semantically "safe," preserving the original meaning while effectively disrupting length-based shortcuts.

Momentum Contrast

To expand the pool of negative examples without increasing batch size, ESimCSE adopts a momentum contrast mechanism. A momentum encoder—a slowly moving average of the primary encoder's weights—generates embeddings for sentences from previous mini-batches. These embeddings are stored in a fixed-size queue, allowing the model to contrast the current sentence against a significantly larger set of negative samples.

Results

ESimCSE was evaluated on seven standard Semantic Textual Similarity (STS) datasets and compared against various BERT and RoBERTa-based baselines.

Performance comparison of ESimCSE against state-of-the-art models across seven STS tasks.

As shown in the results, ESimCSE-BERT$_{base}$ achieved an average Spearman correlation of 78.27%, a 2.02% improvement over the original SimCSE. Ablation studies confirmed the individual contributions of the proposed methods: on the STS-B development set, word repetition alone provided a 1.64% boost, while momentum contrast added 1.53%. Notably, ESimCSE demonstrated greater robustness to simple word overlap compared to SimCSE, indicating a more sophisticated understanding of semantics.

Conclusion

ESimCSE successfully enhances unsupervised sentence embeddings by breaking the length bias inherent in SimCSE and leveraging a larger set of negative samples through momentum contrast. While the framework shows substantial gains in semantic similarity tasks, future work will focus on refining the objective function to better discriminate between negative pairs and improving performance on downstream transfer tasks.

Summary updated

BibTeX
@inproceedings{wu2022esimcse,
  author = {Xing Wu and Chaochen Gao and Liangjun Zang and Jizhong Han and Zhongyuan Wang and Songlin Hu},
  title = {{ESimCSE: Enhanced Sample Building Method for Contrastive Learning of Unsupervised Sentence Embedding}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2022},
  url = {https://openreview.net/forum?id=jr0_bwT515i},
}
Figure