Abstract
Contrastive learning has become a cornerstone for unsupervised sentence embedding. The current state-of-the-art, unsupervised SimCSE (unsup-SimCSE), utilizes dropout as a minimal data augmentation strategy. However, by passing the same input sentence through a Transformer encoder twice, unsup-SimCSE creates positive pairs with identical lengths. This leads to a "length bias," where the model incorrectly associates sentence length with semantic similarity. To address this, we propose ESimCSE (Enhanced Unsup-SimCSE), which introduces a word repetition strategy to break the length symmetry in positive pairs and momentum contrast to expand the pool of negative pairs. Our experimental results on Semantic Textual Similarity (STS) tasks demonstrate that ESimCSE outperforms SimCSE by an average Spearman correlation of 2.02% on BERT-base.
The Problem: Length Bias in SimCSE
SimCSE's success relies on using dropout as a noise source to generate two different embeddings for the same sentence. While effective, this approach ensures that both embeddings in a positive pair share the exact same length and positional information. Because Transformers rely heavily on positional embeddings, the model learns a "shortcut": it assumes that sentences of similar lengths are semantically similar. Statistical analysis confirms that SimCSE's performance is biased toward length similarity, which hinders its ability to capture deeper semantic nuances.
Proposed Methodology: ESimCSE
ESimCSE introduces two key modifications to the standard contrastive learning framework:
- Word Repetition (for Positive Pairs): Instead of using the exact same sentence, ESimCSE modifies the input by randomly duplicating words or sub-words. This simple operation changes the sentence length and shifts positional embeddings without altering the core semantic meaning. Sub-word repetition (duplicating tokens after the BERT tokenizer) was found to be particularly effective in breaking the length bias.
- Momentum Contrast (for Negative Pairs): Contrastive learning benefits from a large number of negative examples. However, increasing batch sizes is computationally expensive. ESimCSE adopts Momentum Contrast (MoCo) from computer vision, maintaining a queue of embeddings from previous batches. A momentum-updated encoder ensures these embeddings remain consistent, allowing the model to compare against thousands of negative samples efficiently.
Experimental Results
We evaluated ESimCSE on seven standard Semantic Textual Similarity (STS) tasks. As shown in the results table, ESimCSE consistently outperforms previous state-of-the-art models across various architectures.
On BERT-base, ESimCSE achieved an average Spearman correlation of 78.27%, a 2.02% improvement over the original SimCSE. These gains were consistent across BERT-large, RoBERTa-base, and RoBERTa-large models. Ablation studies further revealed that both word repetition and momentum contrast contribute significantly to the overall performance, with their combination yielding the best results.
Conclusion
ESimCSE effectively mitigates the length bias inherent in SimCSE by introducing simple yet powerful modifications to the sample building process. By varying sentence length through word repetition and expanding negative samples via momentum contrast, ESimCSE sets a new benchmark for unsupervised sentence embeddings, proving that addressing architectural "shortcuts" can lead to more robust semantic representations.
Summary updated