Choosing an embedding model

In one sentence

Pick the embedding model by measuring retrieval on your own queries, then weigh dimensions, max input, languages, latency and price; leaderboards only shortlist, and switching later means re-embedding everything.

Analogy: Choosing a library's catalog system: a better one finds books faster, but switching means re-cataloguing every book on the shelves.

Leaderboards shortlist; constraints (languages, max input, hosting) filter; your own labelled queries decide.

How it works

  • It maps text to a vector where similar meanings land close, so it defines "relevant" for first-stage retrieval.
  • Use MTEB only to shortlist: label ~100–500 real queries and compare recall@10 and nDCG@10.
  • Dimensions cost storage: 1,024 float32 dims ≈ 4 KB per vector; Matryoshka models truncate to 256–512 with small loss.
  • Check max input: many BERT-era models stop at 512 tokens and silently truncate longer chunks.
  • Vectors from different models, even versions, are not comparable: re-embed into a new index and switch an alias.

Check yourself

Answer to mark it learned; your answers aren't scored.

To save time, a teammate proposes embedding only new documents with a newer embedding model, leaving the existing 2M vectors from the old model in the same index. What happens?

Go deeper

Full explanation

An embedding model maps text to a fixed-length vector so that similar meanings land close together (Embeddings). In RAG it decides what "relevant" means for first-stage retrieval, and it is expensive to change later.

What to compare:

  • Retrieval quality on your data. The MTEB leaderboard is a shortlist, not an answer: it averages many tasks and public datasets, some of which models have trained on. Label ~100–500 real queries and compare recall@10 and nDCG@10.
  • Dimensions = storage. float32 costs 4 bytes per dimension: 1,024 dims ≈ 4 KB per vector, ~4 GB per million chunks before index overhead. Matryoshka-trained models (OpenAI text-embedding-3, Nomic, recent Voyage and Jina) can be truncated to 256–512 dims with a small loss.
  • Max input. 512 tokens for many BERT-era models, ~8k for text-embedding-3 and BGE-M3. Longer chunks are silently truncated.
  • Languages and domain. Multilingual (BGE-M3, multilingual-E5, Cohere) vs English-first; code, legal, medical.
  • Latency, price, hosting. APIs (OpenAI, Cohere, Voyage, Google) are zero-ops; open models (BGE-M3, E5, GTE, Qwen3-Embedding) run on your GPUs, keep data in-house and can be fine-tuned (Fine-tuning embeddings & rerankers).

Vectors from different models are not comparable, not even across versions of one model: switching means re-embedding the whole corpus (Index freshness & lifecycle).

Code Compare candidate models by recall@10 on your own data
pythonCompare candidate models by recall@10 on your own data
import numpy as np
from sentence_transformers import SentenceTransformer

# model -> (query prefix, document prefix). Forgetting E5's prefixes silently costs recall.
CANDIDATES = {
    "BAAI/bge-m3": ("", ""),
    "intfloat/multilingual-e5-large": ("query: ", "passage: "),
}

def recall_at_k(model_id, queries, docs, relevant, k=10, dims=None) -> float:
    """relevant[i] = set of doc indices that answer queries[i]."""
    q_pre, d_pre = CANDIDATES[model_id]
    model = SentenceTransformer(model_id, truncate_dim=dims)  # dims: Matryoshka cut
    D = model.encode(docs, prompt=d_pre, normalize_embeddings=True, batch_size=64)
    Q = model.encode(queries, prompt=q_pre, normalize_embeddings=True)
    top = np.argsort(-(Q @ D.T), axis=1)[:, :k]  # dot product = cosine on unit vectors
    return float(np.mean([len(set(t) & rel) / len(rel) for t, rel in zip(top, relevant)]))

queries, docs, relevant = load_eval_set()  # ~200 real queries with labelled chunks
for model_id in CANDIDATES:
    print(model_id, f"recall@10 = {recall_at_k(model_id, queries, docs, relevant):.3f}")
# Then rerun the winner with dims=256/512 and weigh storage against recall.
Real example

A LATAM fintech shortlists the top English model on MTEB for a Spanish and Portuguese support corpus. On 300 labelled real tickets its recall@10 trails BGE-M3, a multilingual model ranked lower overall. They self-host BGE-M3 on one GPU to keep customer data in-house: ~2M chunks × 1,024 dims × 4 bytes ≈ 8 GB of vectors. A year later a better model ships; adopting it means re-embedding all 2M chunks into a new index, writing to both while it backfills, and switching an alias once evals pass.

Trade-offs +3 · −3

+ You gain

  • Dense embeddings match meaning, not just words: synonyms, paraphrases, cross-lingual queries.
  • Documents are embedded once offline; each query costs one cheap call.
  • Matryoshka truncation and int8/binary quantization shrink storage 4–32× when needed, with a measurable recall cost.

− You pay

  • Lock-in: a new model means re-embedding the corpus and rebuilding the index.
  • Weak on exact identifiers, part numbers and rare terms; pair it with BM25.
  • Public benchmark scores often don't transfer to your domain or language.

Use it when

Every dense or hybrid retrieval system needs this decision. Revisit it when you add languages or a new domain (code, legal, medical), or when retrieval recall is the measured bottleneck.

Avoid it when

Don't switch models to chase a one- or two-point leaderboard gain: re-embedding, dual indexing and re-tuning usually cost more. Fix chunking or add a reranker first.

Numbers to know 5
  • OpenAI text-embedding-3-small: 1,536 dims, $0.02 per 1M tokens; -large: 3,072 dims, $0.13 per 1M (list prices as of 2026); max input 8,191 tokens.
  • float32 storage = dims × 4 bytes: 1,024 dims ≈ 4 KB per vector, ~4 GB per 1M chunks.
  • OpenAI reports text-embedding-3-large cut to 256 dims still beats ada-002 at 1,536 dims on MTEB.
  • BGE-M3: 1,024 dims, up to 8,192 input tokens, 100+ languages, dense + sparse + multi-vector outputs.
  • Quantization: int8 is 4× smaller than float32, binary is 32× smaller.
Common pitfalls 4
  • Forgetting model-specific prefixes or instructions (E5's query: / passage:): recall drops with no error.
  • Mixing vectors from two models or versions in one index: similarities become meaningless.
  • Chunks longer than the model's max input get truncated, so their tail is never searchable.
  • Choosing on the MTEB average instead of its retrieval tasks in your language and domain.
Interview questions 2

Answer out loud first, then reveal.

How would you choose an embedding model for a new RAG system?Show answer

I use MTEB's retrieval scores only to shortlist, then apply hard constraints: languages, max input versus my chunk size, data residency and budget. I take three or four candidates, at least one API and one open model, run them over a few hundred real queries with labelled relevant chunks, and compare recall@10 and nDCG@10 alongside p95 latency and cost per million tokens. I also test Matryoshka truncation, since halving dimensions halves storage. Then I pick the cheapest model within a point or two of the best: a reranker can recover precision, but nothing recovers lost recall.

We want to upgrade our embedding model. What's the plan?Show answer

Vectors from different models live in different spaces, so this is a migration, not a config change. First I evaluate the new model offline on our eval set. If it wins clearly, I re-embed the whole corpus into a new index as a rate-limited, budgeted batch job, while the old index keeps serving and new documents are written to both. Then I shadow or A/B real traffic, compare retrieval and answer metrics, and flip an alias. The old index stays until rollback is no longer needed, and every index records its model id and version.