Text Embeddings by Weakly-Supervised Contrastive Pre-training
arXiv ↗PDF ↗Paper ↗Website ↗Code ↗
TL;DR. E5 builds CCPairs, about 1.3B weak (query, passage) pairs from Reddit, StackExchange, Wikipedia, S2ORC, Common Crawl and news, and filters them to about 270M with a consistency filter. It pretrains BERT-style encoders contrastively in batches of 32,768 pairs, providing 32,767 in-batch negatives per query, then fine-tunes on NLI, MS MARCO and NQ with cross-encoder distillation. E5-PT base was the first unsupervised model to beat BM25 on BEIR.
Key idea
Section titled “Key idea”Weak pairs, filtered. Structured web text gives natural pairs: post and comment, question and upvoted answer, entity name and passage, title and abstract. Most are noisy. E5 trains a model on all 1.3B pairs, then keeps a pair only if its passage ranks in the top 2 among 1M random passages for that query.
Contrastive pretraining. One shared encoder with query: and passage: prefixes, mean pooling, and cosine similarity divided by . The loss is InfoNCE with in-batch negatives only. Batch 32,768, 20k steps (about 2.5 epochs), maximum length 128. Models are small, base and large (33M, 110M, 330M), initialised from MiniLM, BERT-base and BERT-large.
Fine-tuning. NLI, MS MARCO and NQ with 7 mined hard negatives per query, batch 256, and a loss that mixes distillation from a cross-encoder with the contrastive loss:
Results
Section titled “Results”Without labeled data, E5-PT base reaches 42.9 average nDCG@10 on BEIR versus 41.7 for BM25, and E5-PT large reaches 44.2. After fine-tuning, the MTEB averages over 56 datasets are 58.9, 60.4 and 61.4 for small, base and large, against 55.6 for E5-PT base before fine-tuning. E5-base is competitive with GTR-xxl and Sentence-T5-xxl, which have about 40× more parameters. The arXiv record lists no venue.
Connections
Section titled “Connections”- Recipe hub: Embedding recipes compared.
- Successor: E5-Mistral drops weak-pair pretraining for a 7B LLM and synthetic data.
- Same two-stage recipe, open data: Nomic Embed and BGE-M3.
- Better negatives: NV-Retriever studies how to mine hard negatives without false negatives.
- Evaluation: MTEB and MMTEB.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
E5 starts from about 1.3B noisy pairs and keeps a pair only if a model trained on all of them ranks its passage in the top 2 among 1M random passages, leaving about 270M. Pretraining uses batch size 32,768 for 20k steps. (a) What fraction of pairs survives, and how many epochs does pretraining cover? (b) How many negatives does each query see per step, and how does that compare with fine-tuning at batch 256 with 7 hard negatives per query, if hard negatives are shared across the batch? (c) Table 5 gives 51.6 / 50.2 / 45.8 average nDCG@10 for batches of 32k / 8k / 1k. What does the shape of that curve suggest about spending compute on more negatives versus better ones?
What a strong answer covers
- (a) 270M / 1.3B ≈ 21% kept. 20k × 32,768 ≈ 655M pairs ≈ 2.4 passes over 270M, matching the paper's "approximately 2.5 epochs".
- (b) Pretraining: 32,767 in-batch negatives per query, all random. Fine-tuning: 256 × 8 − 1 = 2,047 candidates if every positive and hard negative is shared, of which 7 per query are mined to be hard.
- (c) From 1k to 8k: +4.4 points; from 8k to 32k: +1.4. Returns to more random negatives shrink quickly. Each extra hard negative is far more informative, which is why the fine-tuning stage can use a 128× smaller batch.
- Caveat: the paper also tried pre-batch negatives (64k) and MoCo (130k), and both did worse than 32k in-batch negatives (43.3 and 45.5 vs 51.6, Table 8), because stale negatives come from older parameters. Negative count alone is not the variable.
- Mechanism
Explain why the consistency filter improves the data rather than just shrinking it, using the memorization argument the authors give. Then explain why E5 adds "query: " and "passage: " prefixes to a single shared encoder, and what failure the fine-tuning loss (KL to a cross-encoder plus 0.2 × contrastive) is designed to fix.
What a strong answer covers
- Networks trained on noisy labels fit the clean, consistent pairs first and memorise the noise later. A model trained on all 1.3B pairs therefore scores true pairs highly, and pairs it cannot place in the top 2 out of 1M are likely to be noise (for example, a Reddit reply unrelated to its post).
- The risk is a self-confirmation bias: pairs that are hard but correct can also be filtered out. The paper chose k = 2 by manual inspection rather than by a downstream metric.
- One encoder with prefixes gives an asymmetric model at no extra parameter cost: the same weights can embed short queries and long passages differently. The paper says this matters when the corpus contains paraphrases of the query, which a symmetric model would rank too high. For pairs with no natural direction (citation pairs), the query side is chosen at random.
- Weak pairs teach topical relatedness but not fine relevance. The cross-encoder provides graded scores over the hard negatives, so KL distillation teaches the student how much less relevant each negative is, while the contrastive term keeps the gold label.
- Critique
E5 is presented as the first model to beat BM25 on BEIR without labeled data (42.9 vs 41.7 for E5-PT base). Table 6 shows that fine-tuning on MS MARCO + NQ gives the best retrieval (50.3), NLI gives the best STS (81.1) and their combination is in between (48.7 retrieval, 81.0 STS). Critique the "no labeled data" claim and the use of one model for all tasks, and propose a falsifying experiment.
What a strong answer covers
- Weak pairs from Wikipedia, StackExchange, Reddit and S2ORC overlap with BEIR domains (Wikipedia-based NQ and HotpotQA, CQADupStack, SciDocs, SciFact), so "unsupervised" still means in-domain web structure. The 1.2-point margin over BM25 is small.
- The consistency filter uses a model trained on the same pairs, and k was set by inspection, so there is no held-out selection, but the filtering still shapes the data toward what the model finds easy.
- Table 6 shows a real trade-off: mixing retrieval and NLI data costs 1.6 retrieval points relative to retrieval-only data. A single general embedding is not free.
- Falsifying test: remove from CCPairs all sources that match a BEIR corpus domain and re-evaluate unsupervised BEIR per dataset. If the gain over BM25 vanishes on the matched domains, it came from domain overlap.