Retrieval
Choosing an embedding model
How to pick an embedding model by running a small bake-off on your own documents, weighing quality, dimension, input length, language and cost.
There are many embedding models, and public leaderboards rank them on averages across many tasks. Your documents may rank the models differently. The practical answer is a small test on your own data, judged against a few constraints: quality, dimension, input length, language, cost and storage.
Concept
A Matryoshka model is trained so that the first part of its vector still works on its own. You can keep, for example, the first 256 numbers of a 1,024-number vector and accept a small loss in quality.
The menu, as of 2025 to 2026
| Family | Typical dimensions | Notes |
|---|---|---|
all-MiniLM-L6-v2 | 384 | Fast, cheap CPU baseline for prototypes |
| BGE, E5 and Nomic open models | 384 to 768 | Strong open weights. Check the model card for query and passage prefixes |
OpenAI text-embedding-3-small | 1,536, truncatable | Managed API with Matryoshka dimensions |
OpenAI text-embedding-3-large | 3,072, truncatable | Higher quality, more storage |
| Voyage, Cohere and others | Varies | Compare on your own eval set, not marketing pages |
Six questions to ask
- Quality on your task. Start from the MTEB leaderboard. It averages many tasks, so confirm the ranking with a small test on your documents.
- Dimension. Storage and index memory grow with dimension.
- Maximum input length. Many models cap around 512 tokens. Longer chunks are cut off silently.
- Languages. English-only models degrade on other languages. Pick a multilingual model if your corpus mixes them.
- Cost and latency. API embeddings are cheap at small scale. Re-embedding tens of millions of documents often is not.
- Truncation. Matryoshka models let you store shorter vectors and accept a small quality drop.
Walking through the storage math
Suppose you have 2,000,000 chunks and a 1,024-dimension model that stores each number as a 4-byte float.
Raw vectors: 2,000,000 × 1,024 × 4 bytes = 8.192 GB ≈ 7.6 GiB
Truncated to 256: 2,000,000 × 256 × 4 bytes = 2.048 GB ≈ 1.9 GiBTruncating from 1,024 to 256 numbers cuts raw storage by a factor of four. An in-memory HNSW index adds overhead on top. Plan RAM at roughly 2 to 4 times the raw vector size.
How to run a small bake-off
- Collect 50 to 200 real queries, and mark which chunks should answer each one.
- Embed the corpus with two candidate models. Start with two, not ten.
- Measure recall@5 and MRR for each model.
- Record embedding latency and cost per million tokens.
- Pick the best trade-off for your constraints, and put the model ID in config.
Trade-off
Choose an open model you can host when latency, privacy or re-embedding cost matters most. Choose a managed frontier API when quality matters more than operations and you rarely re-embed. A reasonable default is an open bi-encoder or text-embedding-3-small, plus an eval of about 100 queries. Switch only when the eval moves.
Common mistakes
- Picking by leaderboard rank alone. The ranking may not match your documents.
- Sending chunks longer than the model's limit. The index then holds only the first part of each chunk.
- Mixing vectors from two models in one index.
Check yourself
- Your chunks average 2,000 tokens and the model caps at 512. What does the index hold? Only about the first quarter of each chunk, since 512 is about 26% of 2,000. The rest is dropped without an error.
- You truncate 1,024 dimensions to 256 to save storage. What must you measure? Retrieval quality on your own eval set, since truncation costs some accuracy.
Key takeaways
- Choose a model with a bake-off on your own queries and documents.
- Check the dimension, input limit, languages and cost, not just quality.
- Storage scales with the number of vectors times their dimension.
- Re-embedding is needed whenever you change models.
Further learning
Next, see how embeddings show up in retrieval on embeddings.
Related
Embeddings and similarity
Turning text into vectors, measuring similarity, and choosing an embedding model.
Vector search and vector databases
Approximate nearest neighbor algorithms (HNSW, IVF, PQ) and choosing between pgvector and dedicated stores.
Bi-encoders and cross-encoders
Why retrieval encodes the query and documents separately, why reranking reads them together, and how the two work in sequence.