Özer Cem KELAHMETKELAHMET
Articles · Embeddings

Embedding models for RAG: how they work, how to read MTEB and what dimensions really cost

An embedding model decides which passages a RAG system can find by meaning. This guide explains bi-encoders and contrastive training with worked numbers, shows how to read MTEB scores safely, and prices dimensions in memory, compute and API spend.

Download Markdown
At a glance
Reading time
14 min
Sections
8
Code examples
3
Tables
2
Sources
8
Published
24 Nov 2026
In 30 seconds
What changed
MTEB 2.27 adds label cleaning for benchmark tasks
Why it matters
The practical choice is between a hosted embedding API and an open model you run yourself.
What to do
Shortlist three models, not one

Dense retrieval rests on one component: the embedding model. It turns a question and every chunk of your documents into lists of numbers, called vectors, so that texts with similar meaning end up close together. If the model places "how do I cancel my subscription" near the paragraph on ending a contract, retrieval works. If it does not, nothing later in the pipeline can fix it.

Choosing an embedding model is also one of the most expensive decisions in a retrieval-augmented generation (RAG) system to reverse. Every vector in the index belongs to one model. Switch models and you re-embed everything. This month the main open-source evaluation toolkit, MTEB, shipped data-cleaning features that change how fairly models can be compared, and the most used embedding library kept up its release pace. This article explains how embedding models work, how they are trained, how to read benchmark results, and what each extra dimension costs.

Think of an embedding model as a librarian who files every book on a giant map by subject. Books on similar subjects sit near each other. Your question gets a spot on the same map, and the retriever simply looks around that spot.

What happened

MTEB 2.27 adds label cleaning for benchmark tasks (5 November 2026)

The Massive Text Embedding Benchmark (MTEB) Python package released 2.27.0 on 5 November 2026 and had reached 2.27.22 by 23 November. The project's "What's New" page says v2.27 adds utilities in mteb.data_cleaning to remove samples whose content carries more than one label (remove_conflicting_labels) and samples that carry none (remove_unlabeled). The same page lists an unreleased v2.28 change that passes real frame timing to video embedding models and warns that video scores computed with earlier versions are not comparable.

MTEB 2.26 adds train-leakage removal (15 October 2026)

Version 2.26.0, released on 15 October 2026, added remove_train_leakage, which removes evaluation samples that also appear in a task's training split, with a related remove_duplicates utility across splits. Leakage matters for anyone reading leaderboards: a model trained on data that overlaps a test set can score well without generalising.

Sentence Transformers 6.3.0 (11 November 2026)

Sentence Transformers, the library most open embedding models are loaded with, released 6.3.0 on 11 November 2026. The 6.x line began with 6.0.0 on 18 August 2026, and the README now covers four model types in one package: dense embedding models, Cross-Encoder rerankers, Sparse Encoder models and Multi-Vector Encoder models for ColBERT-style late interaction. The SentenceTransformer class in 6.3.0 exposes encode_query and encode_document methods, which apply each model's own query and document prompts.

How an embedding model works

Most retrieval embedding models are bi-encoders: one transformer encodes the query, the same (or a twin) transformer encodes each document, and the two vectors are compared with a simple similarity function. Because documents are encoded independently of any query, you can embed them once, store the vectors, and search millions of them in milliseconds.

The steps for one text are:

  1. Tokenise the text into subword tokens.
  2. Run the transformer to get one vector per token, each informed by the whole input.
  3. Pool the token vectors into one vector, usually by averaging them (mean pooling) or by taking a special token's vector.
  4. Normalise the vector to length 1.

After normalisation, cosine similarity and the dot product are the same number. A quick NumPy check on two random 768-dimension vectors (seed 0) gives 0.041216 both ways. This is why many vector databases let you choose "dot" for normalised embeddings: it skips two square roots per comparison.

Asymmetric prompts. Queries are short questions; documents are long statements. Many current models are trained with a different instruction prefix for each, such as "query:" and "passage:", or a task description. Using the wrong prefix, or none, can noticeably lower retrieval quality for models trained with prefixes. In Sentence Transformers, model.encode_query(...) and model.encode_document(...) apply the prompts the model's authors configured.

Bi-encoders versus alternatives. A cross-encoder reads query and document together and is more accurate, but must run once per pair, so it is used for reranking a short list, not for search. Multi-vector models such as ColBERT keep one vector per token and score with late interaction, which is more precise than one vector per chunk at the cost of much more storage. The site's ColBERT page covers that design.

How embedding models are trained: contrastive learning

Embedding models learn from pairs: a query and a passage that answers it, a title and its article, a question and its accepted answer. Training pushes each pair together and pushes everything else apart. The standard loss is InfoNCE, explained on the site's InfoNCE page:

loss = −log( exp(s⁺ / τ) / Σⱼ exp(sⱼ / τ) )

Here s⁺ is the similarity between the query and its positive passage, the sum runs over the positive and all negatives (often the other passages in the same batch), and τ is a temperature. The loss is the cross-entropy of picking the right passage out of the batch.

A worked example. The query's similarities are 0.80 to its positive and 0.50, 0.30 and 0.10 to three negatives.

import numpy as np

s = np.array([0.80, 0.50, 0.30, 0.10])   # positive first
for tau in (1.0, 0.05):
    p = np.exp(s / tau) / np.exp(s / tau).sum()
    print(f"tau={tau}: p(positive)={p[0]:.3f} loss={-np.log(p[0]):.3f}")

With τ = 1.0 the model gives the positive a probability of only 0.352 and the loss is 1.045, even though the positive already has the highest similarity. With τ = 0.05 the probability is 0.997 and the loss is 0.003. A low temperature sharpens the softmax, so small similarity gaps produce large probability gaps. That is why trained embedding models often show cosine similarities bunched in a narrow range: the absolute values matter less than the ranking.

Two training details explain much of the quality difference between models. Hard negatives, passages that look relevant but are not, teach finer distinctions than random negatives. Batch size matters because every other passage in the batch is a free negative; larger batches give harder, more varied negatives. The same idea, applied to images and captions, is what the site's CLIP contrastive learning simulation visualises; the broader method is covered on the contrastive learning page.

Reading MTEB without fooling yourself

MTEB groups many tasks, including retrieval, classification, clustering, reranking and semantic similarity, and reports one score per task type plus averages. For RAG, the column that matters most is retrieval, usually measured with nDCG@10: a score that rewards putting relevant passages near the top of the first ten results.

Four habits make the leaderboard more useful:

Table 1. Reading MTEB without fooling yourself
Habit Why it matters
Read the retrieval score, not the overall average Classification and clustering tasks can lift the average without helping search
Check the language and domain of the tasks A model strong on English web text may be weak on German contracts or source code
Check for training overlap Models trained on benchmark training splits or near duplicates can overfit; MTEB's new leakage and label-cleaning tools exist for this
Compare at your dimension and precision A model's score at its full dimension says little about its score after truncation or int8 storage

The best test is still your own. Fifty to two hundred real questions with known answer passages, scored with recall@k and nDCG@10, will tell you more than a leaderboard average. The MTEB package lets you define your own tasks, so the same code can score public benchmarks and your private set.

What dimensions really cost

Embedding dimension is a cost multiplier on everything downstream. The script below prices an index of 10 million chunks.

N, tokens_per_chunk = 10_000_000, 400
for d in (384, 768, 1024, 1536, 3072):
    gb = {k: N * d * b / 1e9 for k, b in (("fp32", 4), ("fp16", 2), ("int8", 1))}
    print(d, {k: round(v, 1) for k, v in gb.items()}, f"FLOPs/query {2*N*d:.2e}")
price_per_m = 0.10                          # example price, dollars per 1M tokens
print("embedding cost:", N * tokens_per_chunk / 1e6 * price_per_m, "dollars")
Table 2. What dimensions really cost
Dimension float32 float16 int8 Brute-force FLOPs per query
384 15.4 GB 7.7 GB 3.8 GB 7.68 × 10⁹
768 30.7 GB 15.4 GB 7.7 GB 1.54 × 10¹⁰
1,024 41.0 GB 20.5 GB 10.2 GB 2.05 × 10¹⁰
1,536 61.4 GB 30.7 GB 15.4 GB 3.07 × 10¹⁰
3,072 122.9 GB 61.4 GB 30.7 GB 6.14 × 10¹⁰

These figures are raw vectors only; an HNSW graph adds its own links on top. Three conclusions follow. Memory scales linearly with dimension and bytes per number, so 3,072 dimensions in float32 need eight times the memory of 384 dimensions in float32 and 32 times that of 384 dimensions in int8. Approximate indexes avoid the brute-force compute, but the per-comparison cost inside them still scales with dimension. And the one-off API cost of embedding is often small next to storage: 10 million chunks of 400 tokens is 4 billion tokens, which at an example price of 0.10 dollars per million tokens is 400 dollars.

Dimension is not the same as quality. A well-trained 768-dimension model can beat a weaker 3,072-dimension one on your data. Models trained with Matryoshka representation learning let you cut vectors to a prefix with a modest loss; the site's article on Matryoshka embeddings and binary quantisation measures those trade-offs, so this article does not repeat them.

What it means in practice

The practical choice is between a hosted embedding API and an open model you run yourself. Hosted APIs remove operations work; open models give you control over versions, data residency and cost at high volume. Both are fine starting points. What is not fine is choosing on a leaderboard average alone.

MTEB's new cleaning tools are a quiet but useful change. Leakage and conflicting labels inflate scores in ways that do not carry over to your documents. As benchmark maintainers clean tasks, older and newer scores may not be comparable, which is another reason to keep your own evaluation set.

Plan model changes as migrations, not swaps. The safe pattern is to build a second index with the new model while the old one keeps serving, run both on your evaluation set, then switch traffic and delete the old index. During the overlap you pay for two indexes, so the memory table above applies twice. For a corpus of 10 million chunks, re-embedding at the example price is a few hundred dollars of API spend, but hours of compute and careful bookkeeping; storing the model name and revision with every vector is what makes the bookkeeping possible.

The query and document prompt convention is now standard enough that libraries expose it as separate methods. Many weak RAG results trace back to a missing prefix. If your model card lists prompts, use them.

For exploring how vectors cluster by meaning, the site's embedding space simulation and embedding map let you see neighbours move as text changes.

What to do now

  1. Shortlist three models, not one. Include one hosted API model, one strong open model and one small fast model as a baseline.
  2. Evaluate on your own questions. Use 50 to 200 queries with known answer passages and measure recall@10 and nDCG@10 for each candidate.
  3. Use the model's query and document prompts. Call encode_query and encode_document in Sentence Transformers, or follow the provider's input-type parameter.
  4. Normalise vectors and use dot product. It is equivalent to cosine for unit vectors and slightly cheaper.
  5. Price the index before you choose a dimension. Multiply chunks by dimension by bytes per number, then add index overhead.
  6. Test reduced precision. Measure recall with float16 and int8 storage before buying memory for float32.
  7. Version every vector. Store the model name and revision with each vector so a future migration knows what to re-embed.
  8. Pair dense with keyword search. Embeddings blur exact identifiers; hybrid search with BM25 catches them.
  9. Re-check leaderboard claims after MTEB updates. Scores computed before data cleaning may shift.

Risks and open questions

Benchmark overfitting is real. Models are increasingly trained on data close to public evaluation sets. MTEB's leakage removal helps, but only for overlaps it can detect.

Domain shift breaks rankings. A model that leads on general web retrieval can trail on legal, medical or code search. Leaderboards rarely contain your domain.

Lock-in is expensive. Every vector belongs to one model. Hosted models can be deprecated, and re-embedding a large corpus costs time and money.

Long inputs are not free. Models with long context windows can embed whole sections, but one vector for 8,000 tokens summarises too much. Chunk size still matters.

Similarity values are not probabilities. A cosine of 0.6 means different things for different models. Thresholds must be calibrated per model.

Watch next: how leaderboard positions change as MTEB's cleaning utilities are applied to more tasks, and whether multi-vector retrieval in mainstream libraries narrows the gap between bi-encoders and rerankers.

Frequently asked questions

What is the difference between an embedding model and an LLM?

An embedding model outputs a fixed-length vector that represents the meaning of a text; it does not generate words. A large language model generates text token by token. Some embedding models are built from LLM backbones, but they are trained and used for a different job.

How many dimensions should my embeddings have?

As many as your evaluation shows you need, and no more. Many models work well at 768 or 1,024 dimensions. Measure recall at each candidate size and precision, then price the memory using dimension times bytes times number of chunks.

Should I use cosine similarity or dot product?

If your vectors are normalised to length 1, they give the same result, and dot product is slightly cheaper. If they are not normalised, follow the model card, because some models are trained for one or the other.

Can I mix embeddings from two models in one index?

No. Vectors from different models live in different spaces, and their similarities are meaningless. To switch models you must re-embed the whole corpus, or run two indexes and fuse their results.

Is the top MTEB model the best choice for my RAG system?

Not necessarily. Look at the retrieval score, the languages and domains of the tasks, model size, licence and cost. Then test the top few candidates on your own questions, because rankings often change on private data.

Summary

Embedding models map questions and passages into one vector space where closeness means relevance. Most are bi-encoders trained with contrastive losses such as InfoNCE, where the temperature turns small similarity gaps into confident rankings, as the worked example showed. MTEB is the standard way to compare them, and its October and November releases added tools to remove train leakage and conflicting labels, a reminder that leaderboard scores need care. Dimensions multiply memory and compute: 10 million chunks at 3,072 float32 dimensions need about 123 GB of raw vectors, versus under 4 GB at 384 int8 dimensions. Choose on retrieval quality measured on your own questions, use each model's query and document prompts, and record the model version with every vector.

Sources

Cite this article

Kelahmet, Ö. C. (2026, November 24). Embedding models for RAG: how they work, how to read MTEB and what dimensions really cost. Özer Cem KELAHMET. https://www.ozercemkelahmet.com/articles/embedding-models-for-rag-choose-measure

BibTeX
@online{kelahmet2026embedding,
  author = {Kelahmet, {\"O}zer Cem},
  title  = {{Embedding models for RAG: how they work, how to read MTEB and what dimensions really cost}},
  year   = {2026},
  month  = {nov},
  url    = {https://www.ozercemkelahmet.com/articles/embedding-models-for-rag-choose-measure}
}
Version historyfirst version
  1. Published

Factual corrections are listed here with what changed. Wording and formatting edits are not listed.

Last updated Nov 24, 2026
Type to search.
    ↑↓ navigate↵ open