CLEAR: Contrastive Learning for Sentence Representation

Zhuofeng Wu, Sinong Wang, Jiatao Gu, Madian Khabsa, Fei Sun, Hao MaarXiv 2020

Introduction

Pre-trained language models like BERT and RoBERTa have revolutionized NLP by mastering word-level context through Masked Language Modeling (MLM). However, these models often struggle to produce high-quality sentence-level representations. The standard approach of using the [CLS] token frequently yields embeddings that are less effective than simple word-vector averaging. CLEAR (Contrastive LEArning for sentence Representation) addresses this gap by introducing a sentence-level objective that forces the model to learn noise-invariant representations.

The CLEAR Framework

CLEAR is inspired by SimCLR, adapting contrastive learning for the discrete nature of text. The framework generates two augmented versions of a sentence and trains the model to maximize the agreement between their representations while minimizing agreement with other sentences in the batch.

The CLEAR framework architecture, showing the dual-stream contrastive objective alongside transformer encoders.

Augmentation Strategies

To create "noisy" versions of sentences, CLEAR employs four primary text augmentation techniques:

  1. Word Deletion: Randomly removing individual tokens.
  2. Span Deletion: Removing continuous blocks of text.
  3. Reordering: Swapping the positions of text spans.
  4. Synonym Substitution: Replacing words with their semantic equivalents.

The model is trained on a joint objective: $L_{total} = L_{MLM} + L_{CL}$. This dual approach ensures the model maintains its word-level understanding while simultaneously refining its sentence-level "big picture" view.

Experimental Setup

The models were pre-trained from scratch on BookCorpus and English Wikipedia. Evaluation was conducted across two major benchmarks:

  • GLUE: Assessing general language understanding across tasks like sentiment analysis and entailment.
  • SentEval: Specifically focusing on Semantic Textual Similarity (STS) to measure the quality of sentence embeddings.

Key Results

CLEAR demonstrated significant improvements over baseline models. On the GLUE benchmark, CLEAR outperformed RoBERTa-base by an average of 2.2%, with notable gains in linguistic acceptability (CoLA) and natural language inference (RTE).

Performance comparison of various CLEAR configurations against BERT and RoBERTa baselines on the GLUE benchmark.

In semantic similarity tasks (STS), CLEAR achieved a +5.7% absolute improvement over RoBERTa-base. These results suggest that the contrastive objective effectively "fixes" the [CLS] token, transforming it into a robust summary of sentence meaning.

Conclusion

By combining word-level MLM with a sentence-level contrastive objective, CLEAR provides a more holistic approach to language model pre-training. While challenges remain regarding hyperparameter sensitivity and the complexity of augmentations, CLEAR establishes a strong foundation for learning high-quality sentence representations without requiring massive input documents or specialized architectures.

Summary updated

BibTeX
@misc{wu2020clear,
  author = {Zhuofeng Wu and Sinong Wang and Jiatao Gu and Madian Khabsa and Fei Sun and Hao Ma},
  title = {{CLEAR: Contrastive Learning for Sentence Representation}},
  year = {2020},
  eprint = {2012.15466},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2012.15466},
}
Figure