Introduction
Universal sentence embeddings—vectors that capture the semantic essence of entire text segments—are a cornerstone of modern Natural Language Processing. Traditionally, high-performing embeddings have relied on large-scale, human-labeled datasets like Natural Language Inference (NLI). However, such data is expensive and often unavailable for specialized domains or low-resource languages. DeCLUTR (Deep Contrastive Learning for Unsupervised Textual Representations) addresses this gap by proposing a self-supervised objective that learns high-quality embeddings directly from unlabelled documents.
Methodology
The core of DeCLUTR is a contrastive learning framework designed to bridge the gap between unsupervised and supervised performance. The model is trained to recognize whether two snippets of text (spans) originate from the same document.
Span Sampling Strategy
The authors introduce a novel sampling strategy to create training pairs:
- Anchor Spans: A relatively long span is sampled from a document.
- Positive Spans: One or more "positive" views are sampled from the anchor's vicinity. These views can overlap with the anchor, be adjacent to it, or be entirely subsumed within it.
- Negative Spans: Spans from other documents in the minibatch serve as "easy negatives," while additional anchors or positives from the same document act as "hard negatives."
The model, typically a transformer like RoBERTa, is trained using the InfoNCE loss. This objective encourages the embeddings of anchor-positive pairs to be closer in vector space than anchor-negative pairs. Notably, the authors employ continued pretraining, combining the DeCLUTR contrastive loss with the standard Masked Language Modeling (MLM) loss to maintain token-level information.
Experimental Setup
The models were trained on a subset of OpenWebText, comprising approximately 500,000 documents. Evaluation was conducted using the SentEval benchmark, which includes 18 downstream tasks (e.g., sentiment analysis, paraphrase detection) and 10 probing tasks to assess the linguistic properties captured by the embeddings.
Results and Discussion
DeCLUTR achieves state-of-the-art unsupervised performance, with DeCLUTR-base reaching an average score of 79.1% on SentEval downstream tasks. This significantly outperforms previous unsupervised methods like QuickThoughts and even exceeds the performance of some supervised models like SBERT on specific tasks, despite using no labeled data.
Key Insights
- Global-to-Local Learning: Sampling longer anchors and shorter positives forces the encoder to relate specific details to broader contexts.
- MLM Regularization: Retaining the MLM objective prevents the model from losing fine-grained information and ensures performance scales with data.
- Hard Negatives: As shown in the figure above, sampling multiple anchors per document (increasing the number of hard negatives) consistently improves the quality of representations.
- Pooling Strategy: Mean pooling across all token embeddings was found to be superior to using the
[CLS]token for universal representations.
Conclusion
DeCLUTR demonstrates that clever self-supervised objectives can close the performance gap between unsupervised and supervised sentence embeddings. While GPU memory constraints currently limit the number of positive spans that can be sampled for larger models, the method's language-agnostic nature and scalability offer a promising path for developing high-quality embeddings in any domain or language without the need for human labels.
Summary updated