Improving Text Embeddings with Large Language Models
TL;DR. E5-Mistral uses GPT-4 (75%) and GPT-3.5-Turbo (25%) to generate 500k synthetic embedding examples (query, positive, hard negative) for 150k task definitions in 93 languages. It then fine-tunes Mistral 7B with LoRA and a standard contrastive loss for fewer than 1k steps. There is no contrastive pretraining on weak pairs. With 13 public datasets added, it reached 66.6 on the 56-task English MTEB, 2.4 above the previous best.
Why it matters now. This paper set the template for 2024–26 LLM embedders: an instruction on the query side only, an LLM backbone, and LLM-written training data. NV-Embed, GritLM, Qwen3 Embedding, Gemini Embedding and Llama-Embed-Nemotron all reuse parts of it, and NV-Embed and NV-Retriever use E5-Mistral itself as the teacher for hard-negative mining. For anyone training a retriever for search agents, it is the clearest test of how far synthetic data can replace labeled retrieval data, and where it cannot.
Key idea
Section titled “Key idea”Synthetic data in two steps. The paper first prompts GPT-4 to brainstorm a list of embedding tasks. It then prompts again, conditioned on one task, to write a JSON example with a query, a positive document and a hard negative. Sampled placeholders control language, query length, clarity and difficulty. Tasks are split into:
- asymmetric tasks, divided by query and document length: short-long, long-short, short-short and long-long;
- symmetric tasks, STS and bitext, which skip the brainstorming step.
A single prompt that produced both task and example gave less diverse data in early experiments. The result is 500k examples, 150k unique instructions and about 180M tokens; 25% of the examples came from GPT-3.5-Turbo.
Instructions on the query side only. A query becomes Instruct: <task definition> + newline + Query: q. Documents get no prefix, so the index is built once and the task is changed only on the query side.
Model and loss. An [EOS] token is appended, and the last-layer [EOS] state of Mistral 7B is the embedding. Attention stays causal. With and , the loss is InfoNCE over in-batch and hard negatives :
Training details:
- LoRA rank 16 on all linear layers, 42M trainable parameters.
- Batch 2,048, learning rate 1e-4, 1 hard negative per pair, maximum length 512.
- About 18 hours on 32 V100s.
- For public datasets without negatives, hard negatives are the top 100 from mE5-base. This is plain top-k mining, not the positive-aware filter NV-Retriever later introduced.
Key results
Section titled “Key results”All numbers are paper-reported; MTEB is the 56-task English set and its retrieval column is 15 BEIR datasets (nDCG@10).
| Setting | Class. | Clust. | Retr. | STS | MTEB avg | Source |
|---|---|---|---|---|---|---|
| BGE-large-en-v1.5 (previous best open) | 76.0 | 46.1 | 54.3 | 83.1 | 64.2 | Table 1 |
| E5-Mistral, synthetic only | 78.2 | 50.5 | 46.9 | 81.2 | 63.1 | Table 1 |
| E5-Mistral, MS MARCO only | 71.6 | 47.1 | 54.4 | 79.5 | 62.7 | Table 5 |
| E5-Mistral, synthetic + MS MARCO | 78.3 | 49.9 | 52.2 | 81.2 | 64.5 | Tables 1, 5 |
| E5-Mistral, full data | 78.5 | 50.3 | 56.9 | 84.6 | 66.6 | Table 1 |
- Commercial comparison (Table 3, MTEB leaderboard of 2023-12-22): BEIR 56.9 versus 55.4 for OpenAI text-embedding-3-large and 55.0 for Cohere embed-english-v3.0.
- Bitext mining (Table 4): BUCC 98.9 (the best listed), Tatoeba 70.1 versus 81.1 for LaBSE.
- Cost of evaluation: one MTEB run takes about 3 days on 8 V100s, even with inputs truncated to 512 tokens.
Limitations & open questions
Section titled “Limitations & open questions”- Inference and storage cost. Every document needs a 7B forward pass and a 4,096-d vector. The authors name Matryoshka training as a possible fix but do not use it.
- Synthetic data does not replace labeled retrieval data. Synthetic-only retrieval is about 10 points below full data, and MS MARCO alone beats synthetic + MS MARCO on BEIR retrieval (54.4 vs 52.2).
- In-domain training sets. The full mix includes the training splits of HotpotQA, FEVER, NQ, Quora and MS MARCO, which have BEIR counterparts. The headline retrieval score is not purely zero-shot.
- Proprietary generator. The data came from GPT-4 and GPT-3.5. The authors list open-source generators as future work; NV-Embed-v2 and Llama-Embed-Nemotron later used open models.
- Evaluated at 512 tokens. Long-context claims rest on one synthetic passkey task.
Connections
Section titled “Connections”- Recipe hub: Embedding recipes compared.
- Predecessor: E5, the weak-pairs-then-fine-tune recipe that this paper replaces with synthetic data.
- Successors on the same backbone: NV-Embed and NV-Retriever use E5-Mistral as the hard-negative teacher; GritLM trains on its data; LLM2Vec uses a public replica of it.
- Self-generated data at scale: Qwen3 Embedding and Gemini Embedding.
- Instructions in retrieval: Promptriever trains instruction-following retrievers in depth.
- Cheaper vectors: Matryoshka representations.
- Evaluation: MTEB and MMTEB, and BRIGHT for held-out reasoning-heavy retrieval.
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-Mistral trains on about 1.8M examples with batch size 2,048 for one epoch, adds 1 hard negative per query, and generated its 500k synthetic examples with about 180M tokens. (a) How many optimizer steps is that? (b) If every in-batch positive and hard negative is a candidate for every query, how many negatives are in each query's InfoNCE denominator, and how does that change with 7 hard negatives as in E5? (c) Tokens per synthetic example, and what that implies about the "long" documents. (d) Index size for 10M passages with 4,096-d float16 vectors.
What a strong answer covers
- (a) 1.8M / 2,048 ≈ 880 steps, consistent with the paper's "fewer than 1k steps".
- (b) 2,048 positives + 2,048 hard negatives = 4,096 candidates, of which 4,095 are negatives. With 7 hard negatives per query, 2,048 × 8 − 1 = 16,383. If only positives were shared, it would be 2,047 + 1 = 2,048.
- (c) 180M / 500k = 360 tokens per example. The paper calls this total token consumption, which probably also counts prompts and the brainstorming calls, so the generated text per example is shorter still. Even "long" synthetic documents are a few hundred tokens at most; the training sequence limit is 512 tokens.
- (d) 4,096 × 2 bytes = 8,192 bytes per vector; × 10M ≈ 82 GB, 5.3× a 768-d float16 index (about 15 GB).
- What if…
Table 5 (trained on synthetic data + MS MARCO) shows that dropping the natural-language instruction costs 4.2 MTEB points, and replacing it with a task-type prefix ("query: " or "classify: ") costs the same 4.2. Break the drop down by category and explain why the prefix matches the full instruction on retrieval but not on classification or STS.
What a strong answer covers
- Default: classification 78.3, retrieval 52.2, STS 81.2. No instruction: 72.3, 48.2 and 76.7. Task-type prefix: 71.1, 52.7 (slightly higher than default) and 73.8.
- For retrieval, the main job of the prefix is to mark the asymmetry: this is a query, the other side is a document. A short tag does that as well as a sentence.
- For classification, clustering and STS, the same text can be embedded along different axes (topic, sentiment, intent). Only a task description says which axis matters, so a generic tag cannot replace it.
- Since documents get no instruction, task changes only touch the query side: one prebuilt index can serve many instructions.
- A clean follow-up: hold the data fixed and vary instruction specificity, then report per-category deltas with seeds, since a 0.5-point retrieval gain is within the usual noise.
- Critique
The paper presents "synthetic data only" (63.1 MTEB) as competitive without any labeled data, and "full data" (66.6) as a new state of the art on BEIR and MTEB. Using the per-category numbers in Tables 1 and 5 and the training-data list in Appendix A, critique both claims as an IR evaluator and propose one falsifying experiment.
What a strong answer covers
- Retrieval does not follow the average: synthetic only gets 46.9 on the 15 BEIR sets, MS MARCO only gets 54.4, synthetic + MS MARCO 52.2, and full data 56.9. Synthetic data alone is about 10 points behind on retrieval; most of its gain over MS MARCO only is in classification (71.6 → 78.3).
- The full-data mix includes the training splits of HotpotQA, FEVER, NQ, Quora and MS MARCO, which are also BEIR or MTEB test sets. The 56.9 retrieval score is therefore partly in-domain, unlike zero-shot baselines.
- Comparisons in Table 3 are with commercial models whose training data is unknown, at one snapshot (2023-12-22), without seeds or significance tests.
- Falsifying test: retrain without any dataset that has a BEIR or MTEB counterpart and evaluate on held-out retrieval sets (for example BRIGHT or a new-domain corpus). If the gap to strong BERT-based models disappears, the gain came from in-domain data, not from the LLM backbone.
- Mechanism
Contrastive pretraining on weak pairs improves XLM-R large by 8.2 retrieval points but has a negligible effect on Mistral 7B. E5-Mistral also keeps causal attention and pools the last [EOS] token. Explain both choices: why weak-pair pretraining matters less for a 7B decoder, and why last-token pooling is the natural choice under a causal mask.
What a strong answer covers
- Weak-pair pretraining teaches an encoder which texts are related, at the scale of hundreds of millions of pairs. A 7B LLM has seen trillions of tokens and already models relatedness implicitly; fine-tuning only has to expose it as a vector.
- Under a causal mask, token i only sees tokens 1…i. Only the final [EOS] state has seen the whole input; mean pooling averages states that saw only prefixes, which over-weights the beginning of the text.
- Table 5 agrees: mean pooling 64.1 and weighted mean 64.0 versus last token 64.5. The gap is small because LoRA can adapt the states either way.
- Cost of the choice: the vector depends heavily on one position, and later work (NV-Embed, LLM2Vec, GritLM) found that removing the causal mask and mean or learned pooling does better.
- The LoRA ablation (r8 64.8, r16 64.5, r32 64.6) suggests that adaptation needs few parameters, which is consistent with little missing knowledge.
- Design
You need single-vector embeddings of 8k-token web pages for a deep-research agent's retriever, and you want to start from E5-Mistral. The paper reports 100% personalized-passkey accuracy within 4k tokens with the default 4k sliding window, worse results when the window is naively widened to 32k, and over 90% within 32k after changing the RoPE base to 1e5. All MTEB evaluation is truncated to 512 tokens. Design the long-document setup and the tests you would run before trusting it.
What a strong answer covers
- Options: (1) chunk pages into 512-token passages and aggregate scores per page (MaxP); (2) a single vector with RoPE base 1e5 and a short fine-tune on long pairs; (3) a model trained for long inputs.
- Passkey retrieval only tests whether one fact survives in the vector; it does not test ranking among many related long documents. The paper notes that the RoPE change costs a little on short inputs.
- Tests: recall@k on long-document retrieval with real queries (for example MLDR, or BrowseComp-Plus evidence pages), comparing chunked versus single-vector at matched index size, and checking where in the page the evidence sits (beginning, middle or end).
- Budget: one 7B forward pass over 8k tokens per page, a 4,096-d vector per page or per chunk. Chunking multiplies index size by about 16 at 512 tokens per chunk.
- Research idea
E5-Mistral suggests that "generative language modeling and text embeddings are the two sides of the same coin": a strong LLM could generate its own training data and then become an embedder. Propose a study that separates three factors: the strength of the data generator, the diversity of tasks, and the backbone, using an academic budget.
What a strong answer covers
- Generator: hold the backbone fixed and generate the same task taxonomy with GPT-4, a smaller open model, and the backbone itself (self-generated, as Qwen3 and Gemini Embedding later did).
- Diversity: at a fixed number of examples (for example 100k), vary the number of unique task definitions (1k, 10k, 100k), using the two-step brainstorm prompt.
- Backbone: repeat on a 0.5–1B model and a 7B model, LoRA only, under 1k steps, as in the paper.
- Evaluation must be held-out from the generator's targets: BEIR and MTEB task types are in the prompts, so add BRIGHT or a new domain. Report retrieval separately from the average, with seeds.
- Expected outcome to test: whether a weaker generator with more task diversity can match a stronger generator, which decides whether the method is affordable without GPT-4.