ConSERT: A Contrastive Framework for Self-Supervised Sentence Representation Transfer

Yuanmeng Yan, Rumei Li, Sirui Wang, Fuzheng Zhang, Wei Wu, Weiran Xu

Introduction: The "Collapse" of BERT Sentence Embeddings

While BERT has revolutionized natural language processing at the token level, its "native" sentence-level representations—obtained via the [CLS] token or averaging token embeddings—are notoriously poor. Research indicates that BERT’s sentence embedding space is anisotropic, meaning embeddings are "collapsed" into a narrow cone.

In practice, this anisotropy causes unrelated sentences to exhibit high cosine similarity (often between 0.6 and 1.0). This phenomenon is largely driven by high-frequency words that dominate the embedding space, obscuring semantic nuances. To make BERT effective for downstream tasks like semantic search or clustering, the embedding space must be "de-collapsed" to become more discriminative.

The ConSERT Framework

To address this, the authors introduce ConSERT (Contrastive Framework for SEntence Representation Transfer). Inspired by contrastive learning techniques in computer vision (like SimCLR), ConSERT fine-tunes BERT to distinguish between different augmented versions of the same sentence.

The ConSERT architecture uses a shared BERT encoder and a contrastive loss layer to align augmented sentence representations.

The framework operates on a simple principle: for any given sentence, the model generates two "augmented" versions. These versions form a positive pair that the model is trained to pull together in the embedding space. Simultaneously, the model is trained to push these representations away from all other sentences in the training batch (the negative pairs).

Data Augmentation Strategies

The effectiveness of ConSERT hinges on its data augmentation module. Since the process is self-supervised and requires no human labels, the authors explored four primary strategies to create noise-perturbed versions of token embeddings:

  • Adversarial Attack: Adding small, calculated perturbations to embeddings to challenge the model.
  • Token Shuffling: Reordering tokens while maintaining their original position IDs.
  • Cutoff: Randomly zeroing out entire rows (tokens) or columns (feature dimensions) in the embedding matrix.
  • Dropout: Utilizing standard neural network dropout as a source of stochastic noise.

Empirical analysis revealed that Token Shuffling and Token Cutoff were the most effective, as they force the model to rely on semantic structure rather than specific keyword memorization.

Key Insights and Results

ConSERT demonstrates remarkable efficiency and performance across Semantic Textual Similarity (STS) benchmarks.

Resolving Anisotropy

The primary achievement of ConSERT is the successful "reshaping" of the embedding space. By applying contrastive loss with an appropriate temperature parameter, the model learns to spread embeddings more uniformly, directly tackling the frequency bias that plagues vanilla BERT.

Comparison of predicted cosine similarity vs. gold similarity scores before (a) and after (b) applying ConSERT. Note the significant reduction in "collapsed" high-similarity scores for unrelated pairs.

Performance Benchmarks

  • Unsupervised Excellence: ConSERT-large achieved an average Spearman correlation of 76.45 across STS tasks, representing an 8% relative improvement over previous state-of-the-art methods like BERT-flow.
  • Supervised Gains: When combined with Natural Language Inference (NLI) supervision, ConSERT reached a score of 81.28, outperforming the widely used Sentence-BERT (SBERT).
  • Extreme Data Efficiency: One of the most significant findings is ConSERT's robustness; training on just 1,000 unlabeled sentences from a target domain yielded a 35% relative performance gain over vanilla BERT.

Conclusion

ConSERT provides a lightweight and highly effective solution for generating high-quality sentence embeddings. By leveraging contrastive learning and clever data augmentation, it transforms BERT from a token-level specialist into a robust sentence-level encoder. Its high data efficiency and fast fine-tuning time make it an ideal candidate for domain-specific applications where labeled data is scarce.

Summary updated

BibTeX
@inproceedings{yan2021consert,
  author = {Yuanmeng Yan and Rumei Li and Sirui Wang and Fuzheng Zhang and Wei Wu and Weiran Xu},
  title = {{ConSERT: A Contrastive Framework for Self-Supervised Sentence Representation Transfer}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.acl-long.393},
}
Figure