This page covers one brick of a RAG system: the model that turns text into a list of numbers. The full chain, and the two places it can break, are in RAG: principle and architecture.
What Is an Embedding?
An embedding is a translation from human language to the language of math. You provide a sentence, the model returns a vector, a list of numbers. The notable part: two texts that talk about the same thing produce vectors that are close together in space. We measure this proximity with cosine similarity (the angle between the two vectors: the smaller it is, the more similar the texts are, the full definition is in norms and distances).
Concrete example: "cat" β [0.8, 0.2, 0.1, ...] and "tiger" β [0.75, 0.25, 0.15, ...] end up close (they're felines). "chair" β [0.1, 0.9, 0.05, ...] is very far away (completely unrelated). It's as if the model placed words on a geographic map where nearby concepts are neighbors.
Early embeddings (Word2Vec, 2013) produced one vector per isolated word, and only one: "bank" got the same vector in "the river bank" and "the central bank". Modern models produce a vector per full sentence or paragraph, computed with the surrounding words in view, so the same word gets a different representation depending on its context. That is what makes them usable for search at all.
How It Works
The process relies on a transformer encoder, usually a BERT (Bidirectional Encoder Representations from Transformers): a model that reads the whole text at once, in both directions, rather than producing it word by word. You pass it the text, it produces a representation for each token. Those representations then have to be collapsed into one vector per sentence, and there are two common ways to do it:
- take the representation of a special token prepended to the sentence, written
[CLS](for classification), whose whole job is to act as a summary; - take the average of the representations of all tokens, an operation called mean pooling.
Since 2024, the best embedding models are no longer BERT models with a few hundred million parameters, but LLMs with several billion, repurposed: instead of having them generate text, you read their internal representation. Because an LLM reads left to right, only the last token has "seen" the whole sentence; so its representation is often the one kept (last-token pooling), or the model is modified to read in both directions. NV-Embed (NVIDIA, 2024) was among the first to top the leaderboard this way; Qwen3-Embedding and Gemini Embedding follow the same path. These models benefit from everything the LLM already knows about languages and domains, at the cost of much heavier computation per text.
NV-Embed: Improved Techniques for Training LLMs as Generalist Embedding ModelsBut a raw model, BERT or LLM, doesn't produce good sentence embeddings. It needs to be trained specifically with a contrastive loss: pairs of similar texts (question + relevant answer) must produce close vectors, and dissimilar pairs must be pushed apart.
Symbol by symbol. is the anchor text (say, a question). is the text that belongs with it (the right answer). ranges over every candidate in the comparison: the right one plus all the wrong ones. is the cosine similarity between the two vectors produced. is the temperature, a number chosen by hand (often around 0.05) that sets how sharp the separation must be: the smaller is, the less of a lead the right candidate needs before the score saturates, and so the harder the model is punished for getting it wrong. is the loss, the quantity training drives down.
In one sentence: the formula measures what share of the total similarity goes to the right candidate, and training pushes that share towards 1. If the right candidate dominates, the ratio is nearly 1, its logarithm nearly 0, and the loss nearly nothing. The denominator (the sum over every candidate) is why the negatives matter as much as the positive: without them, nothing would stop the model from making every vector identical.

Architectures
The bi-encoder, the dominant architecture
"Bi-encoder" means: two separate encodings. The query on one side, the document on the other, each becoming a vector without ever seeing the other, and they only meet at the very end, when a cosine similarity is computed between the two lists of numbers.
The advantage is decisive: you can encode every document ahead of time, offline, and compute only the query vector at request time. That is what makes search over millions of documents possible at all. The cost: since the document is encoded without knowing what will be asked of it, no word of the query can influence its representation. A cross-encoder, which reads the (query, document) pair together, is finer for exactly that reason, but it has to be run on every pair, which rules out applying it to the whole corpus. That is the subject of Reranking: cross-encoders and ColBERT.
More recent: instructions given to the embedding model
Models like E5 or GritLM accept an instruction placed in front of the text, which steers the embedding produced:
- Instruction: "retrieve relevant documents for this query"
- Query: "What is photosynthesis?"
The instruction tells the model which role to play. The same text can therefore yield two different vectors depending on whether it is encoded as a question to ask or a document to index, which partly addresses the question/answer asymmetry that HyDE attacks a different way. One practical consequence worth not missing: if the model expects an instruction, you must give it the same one at indexing time and at search time, or the vectors stop being comparable.
Popular Models in Practice
| Model (vendor, year) | Dimensions | Context (tokens) | Typical use |
|---|---|---|---|
| all-MiniLM-L6 | 384 | 512 | Prototyping, very fast, runs on a laptop |
| BGE-M3 (BAAI, 2024) | 1024 | 8192 | Open, multilingual, the safe bet for self-hosted deployments |
| EmbeddingGemma (Google, 2025) | 768, truncatable down to 128 | 2048 | Open, 308 million parameters, designed to run on a phone |
| Qwen3-Embedding (Alibaba, 2025) | 1024, 2560 or 4096 depending on size, truncatable | 32,000 | Open (Apache 2.0), three sizes from 0.6 to 8 billion, top of the multilingual leaderboard at release |
| jina-embeddings-v3, then v5-text (Jina AI, 2024 and 2026) | 1024 | 8192 (v3), up to 32,000 (v5) | Published weights, small multilingual models |
| E5-mistral-7b-instruct (2024) | 4096 | 32768 | One of the first LLMs converted into an embedding model, expensive and slow |
| Mistral Embed (2023) | 1024 | 8192 | Service, general text, see Mistral Embed |
| Codestral Embed (Mistral, 2025) | 1536 by default, up to 3072, truncatable | 8192 | Service specialised in code, see Codestral Embed |
| OpenAI text-embedding-3-small and -large (2024) | 1536 and 3072, truncatable | 8191 | Service, very widespread |
| Gemini Embedding (Google, 2025) | 3072, truncatable (768 and 1536 recommended) | 2048 | Service, text only |
| voyage-4 and its family (Voyage AI, January 2026) | 1024 by default, from 256 to 2048 | 32,000 | Service; the four sizes share the same space (see below) |
| Cohere Embed v4 (2025), then Embed 5 | 1536 (v4) or 2048 (Embed 5) by default, truncatable | 128,000 | Multimodal service: text, images, PDF pages |
| Gemini Embedding 2 (Google, 2026) | from 128 to 3072 | 8192 | Multimodal service: text, image, video, audio, PDF in one space |
This table deliberately gives no scores. Embedding leaderboard values change with every new submission, and a number copied here would be stale within weeks. The columns that are here are stable properties of the model, the dimension of the vector it emits and the length of text it accepts. For scores, go to today's leaderboard (see below) and read them per task category.
Quick prototyping? A small model from the MiniLM family: free, light, runs on anything. Self-hosted multilingual production? An open model explicitly trained multilingually: BGE-M3, or a small Qwen3-Embedding if you have a GPU. Don't want to host anything? A paid service will do (Gemini, Voyage, Cohere, Mistral, OpenAI), at the price of one network call per text indexed, a dependency on a vendor, and sending your texts to it. In all three cases, the only measurement that counts is the one you make on your own questions: see Evaluating a RAG system.

MTEB: The Reference Benchmark
MTEB (Massive Text Embedding Benchmark) is the collection of trials used to compare these models. In the paper that introduced it, MTEB spans 8 task types, 58 datasets and 112 languages, with 33 models measured on it. The eight types: retrieval, semantic textual similarity (STS), classification, pair classification, clustering, reranking, summarization, and bitext mining (matching translated sentence pairs across languages). The public online leaderboard has grown a great deal since, but the structure is still that one.
MTEB: Massive Text Embedding Benchmark (Muennighoff et al., 2022)
That is the paper's own conclusion: no single model dominates across tasks. A model can be excellent at retrieval and mediocre at classification. Since the headline score averages over 58 datasets, it mixes in trials that have nothing to do with your use. For a RAG system, only the retrieval category is directly relevant.
Here is the reasoning to apply, on figures invented for the demonstration: between a model averaging 62 whose retrieval score is 70, and a model averaging 66 whose retrieval score is 64, take the first one for a RAG. The second one's average is propped up by tasks you will never use. On reading this kind of score in general, see How to read a benchmark score.
MMTEB: The Benchmark Goes Multilingual
In 2025, a large community of researchers published MMTEB (Massive Multilingual Text Embedding Benchmark), an extension of MTEB to more than 500 tasks and more than 250 languages, with new trials: following an instruction, searching long documents, retrieving code. The public leaderboard is now split into several benchmarks (multilingual, English, code, by region), and lighter versions let you evaluate a model without spending days of compute. One finding of the paper is worth keeping: at publication time, the best public model on the multilingual set was not a multi-billion-parameter LLM but a 560-million-parameter model (multilingual-e5-large-instruct). Size helps; it does not decide everything.
MMTEB: Massive Multilingual Text Embedding BenchmarkHugging Face maintains the public, continuously updated leaderboard; it is the practical reference for comparing models, rather than the tables in papers, where every team is presenting its own model. In 2026, the top of the multilingual leaderboard is contested within tenths of a point or a point or two between Google's models (Gemini Embedding, then Gemini Embedding 2), Alibaba's (Qwen3-Embedding), NVIDIA's and a few others, and every vendor reports its score under its own protocol: Qwen3-Embedding-8B claimed 70.58 on the multilingual benchmark in June 2025, Gemini Embedding 2 announces 69.9 in 2026. Two caveats are worth knowing: models may have seen the benchmark's datasets during training, which the leaderboard cannot detect, and a score on these public datasets says nothing about your own documents.
What a Single Vector Cannot Do
A 2025 result from Google DeepMind cast a harsh light on the method itself. Its reasoning is geometric. An embedding model places each document at a point in a space of fixed dimension, and a query retrieves "the k nearest points." Now, the number of different groups of k documents you can bring out this way, by choosing the query cleverly, is limited by the dimension. When the number of combinations you need to retrieve exceeds what the dimension allows, some combinations are simply impossible to obtain, whatever the training.
The authors checked this two ways. First with vectors optimised directly on the expected answers (the most favourable case possible): even then, retrieving every pair of documents in a corpus requires a high dimension. Then with a deliberately simple test set called LIMIT (questions like "who likes apples?" over short profiles of people), on which the best models of the day largely fail, while keyword search or a multi-vector model does much better.
On the Theoretical Limitations of Embedding-Based RetrievalThe practical lesson matches the rest of the module: for queries that combine criteria ("contracts signed in 2024 and containing a termination clause"), one vector per document is not always enough. Hence the value of hybrid search with keywords (retrieval methods), of models with several vectors per document such as ColBERT (reranking), and of metadata filters.
Multimodal Embeddings
One last major development: a single model now places text and images (and sometimes video and audio) in the same space, so a written question can retrieve a photo, a diagram or a PDF page. The idea goes back to CLIP (2021), which aligned images and captions (CLIP); it reached production embedding models in 2025-2026: Cohere Embed v4 and then Embed 5 (text, images and pages mixing both), jina-embeddings-v4 (2025, which outputs either a single vector or, ColBERT-style, one vector per token or image patch), and Gemini Embedding 2 (2026), which accepts text, image, video, audio and PDF.
jina-embeddings-v4: Universal Embeddings for Multimodal Multilingual Retrieval Gemini Embedding 2: A Native Multimodal Embedding Model from GeminiFor a corpus of scanned documents or slide decks, it is an alternative to text extraction: you index the image of each page directly. The multi-vector-per-page approach, ColPali, is presented in RAG: principle and architecture.
Practical Considerations
Dimensions and Storage
The arithmetic is entirely mechanical. One number in FP32 takes 4 bytes, so:
- 384 dimensions Γ 4 bytes = 1,536 bytes, i.e. 1.5 KB per embedding;
- 1 million documents Γ 1.5 KB = 1.5 GB;
- with 3,072 dimensions: 3,072 Γ 4 = 12 KB per embedding, so 12 GB for the same corpus.
The ratio between the two is just the ratio of the dimensions: 3,072 / 384 = 8. A 4,096-dimension model therefore costs a little over ten times the storage of a 384-dimension one, and roughly as much extra compute per comparison, since a comparison is one multiplication per dimension. Before picking the large dimension, the gain in relevance (measured) has to be worth that factor of ten.
Normalization
Most models produce normalized vectors, meaning of length 1 (the L2 norm: length in the ordinary, Pythagorean sense). When that holds, cosine similarity reduces to a dot product (see dot product and projections): multiply the numbers pairwise and add, with no division by the lengths. It is faster, and it is the format most vector databases expect.
Matryoshka Embeddings
Some recent models are trained so that their vectors can be truncated: keep the first 256 dimensions of a 1,024-dimension vector and throw the rest away, recomputing nothing. This only works if the model was trained for it, because the important information has to have been pushed towards the front of the vector. It became the norm in 2024-2026: models from OpenAI, Google, Cohere, Voyage, Alibaba (Qwen3-Embedding), Mistral's Codestral Embed and EmbeddingGemma all offer it. The mechanism is covered in Matryoshka embeddings.
Embedding Quantization
You can also cut the precision of each number instead of cutting their count: FP32 down to INT8, or even to 1 bit per dimension (keeping only the sign). The saving follows directly: 32 bits per number against 1 bit, so 32 times less space for a binary index. The same factor applies to memory bandwidth, which is often the real bottleneck of a search.
The degradation is real but recoverable: the usual practice is to shortlist on the compressed index, then recompute exact scores for the few dozen surviving candidates from the full-precision vectors. You then pay for precision on a handful of documents only.
Fine-tuning on Your Data
For a domain with its own vocabulary (medical, legal, technical), fine-tuning an embedding model on your own texts improves search relevance, sometimes markedly. The model learns that in your corpus, two terms that general language does nothing to connect refer to the same thing.
You'll need: a few thousand pairs (query, relevant document), a library such as Sentence Transformers, and an appropriate loss. The usual one is called MultipleNegativesRankingLoss: it is exactly the contrastive loss written above, except the "negatives" are not collected separately but taken from the training batch itself, for a given pair, the documents of the other pairs in the batch serve as the wrong answers. Hence the name: multiple negatives, for free.
from sentence_transformers import SentenceTransformer, losses, models
model = SentenceTransformer('bge-base')
# Train with your pairs...
Warning: after fine-tuning, the old embeddings are worthless. You must re-index your entire corpus with the new model.
If you change the embedding model (or even just fine-tune it) every old vector becomes unusable. The reason is simple: each model places texts in its own space, and nothing guarantees that dimension 42 of the new model means what dimension 42 of the old one meant. Comparing an old vector to a new one yields a number that means nothing.
A recent exception confirms the rule: some model families are now trained to share one space. The four sizes of voyage-4 (January 2026) produce mutually compatible vectors, as do the fast and precise versions of Cohere's Embed 5: you can index the corpus with the large model and query with the small, cheaper one. But that compatibility is built on purpose, within one family; it holds neither between two families nor between two vendors.
Outside those cases, everything has to be recomputed, which implies either a service interruption or dual indexing during the switchover. On a corpus of several million documents, that is a project, not a configuration change. It is also why reranking, which never touches the index, is a far lighter lever: see Reranking.
The embedding model is the heaviest brick in a RAG chain to change (since changing it forces a re-index) which is why it is worth choosing carefully up front. But if your RAG answers badly, do not assume it is the culprit: start by establishing whether the failure is in retrieval or in writing, using the two separate measurements in evaluating a RAG and the ranking measures in recall@K, precision@K, MRR, NDCG.
1. In the contrastive training of an embedding model, why are negative examples indispensable?
2. You index your corpus with an instruction model (E5-style) giving an instruction, then you search without giving it. What happens?
3. For a RAG system, between a model averaging 62 on MTEB with 70 on retrieval, and one averaging 66 with 64 on retrieval, which should you pick?
4. After fine-tuning your embedding model on your own data, why must the whole corpus be re-indexed?
5. Moving from a 384-dimension model to a 4096-dimension one: what does it cost, and what would justify it?
6. Voyage AI announces that the four sizes of voyage-4 share the same embedding space. What does that make possible?