Introduction
Embeddings—dense vector representations of text—are fundamental to modern natural language processing (NLP), powering applications from semantic search to document clustering. Traditionally, high-quality embeddings were produced using fragmented approaches, with different architectures and objectives tailored to specific tasks like sentence similarity or document retrieval. Furthermore, while large-scale autoregressive models like GPT-3 excel at language generation, they do not inherently produce a single, high-quality "summary" vector. This work introduces a unified approach to creating high-performance embeddings by scaling contrastive pre-training to models with up to 175 billion parameters.
Methodology
The researchers utilize Contrastive Pre-Training (CPT) to align text representations in a shared vector space. The objective is to minimize the distance between "positive" pairs (semantically related text) while maximizing the distance from "negative" pairs.
Model Architecture and Training
The models, termed "cpt-text" and "cpt-code," are initialized with pre-trained generative weights from GPT and Codex, respectively. This initialization leverages the rich linguistic knowledge captured during generative pre-training. The architecture employs a standard Transformer encoder where special [SOS] and [EOS] tokens are appended to the input. The final hidden state of the [EOS] token serves as the text embedding.
A critical component of the training recipe is the use of massive batch sizes (up to 12,288). Large batches provide a higher density of "hard negatives" within each training step, which the authors found essential for achieving state-of-the-art performance. This bi-encoder architecture allows for pre-computing document embeddings, enabling efficient sub-millisecond search over large datasets.
Experimental Setup
The models were evaluated across a diverse set of benchmarks:
- Text: SentEval (classification), MSMARCO, Natural Questions (NQ), and TriviaQA (large-scale search), and the BEIR benchmark (zero-shot retrieval).
- Code: CodeSearchNet, covering six programming languages.
Training data for text consisted of unlabeled internet data where adjacent text segments were treated as positive pairs. For code, pairs of top-level docstrings and their corresponding function implementations were used.
Results and Scaling Laws
The study reveals a clear scaling law for text embeddings: performance consistently improves as model size increases from 300M to 175B parameters.
The cpt-text XL model achieved significant gains over previous unsupervised state-of-the-art (SOTA) methods, including a 23.4% relative improvement on MSMARCO and a 4% improvement in linear-probe classification accuracy. Interestingly, while text models scaled well, cpt-code performance plateaued relatively early, suggesting that current code benchmarks may not yet fully capture the benefits of extreme parameter scaling.
Discussion: The Similarity Trade-off
A notable finding is the divergence in performance across different task types during training. While performance on retrieval (NQ) and general classification (SentEval) improved with more training steps, performance on Sentence Textual Similarity (STS) tasks actually declined.
This suggests that "similarity" is a nuanced concept. For instance, a sentence and its direct negation might be highly relevant for a search query but are considered dissimilar in an STS context. This trade-off indicates that these models, while powerful for search and classification, may not be a universal solution for every embedding application.
Conclusion and Limitations
Scaling contrastive learning with generative initialization produces highly descriptive embeddings capable of state-of-the-art zero-shot performance. However, the high computational cost of training 175B parameter models and the observed decline in STS performance remain challenges. Future work will likely focus on improving training efficiency and addressing the inherent societal biases present in large-scale internet-trained models.
Summary updated