Lesson 4 of 8 · Meaning as Vectors
Choosing an Embedding Model
Choose an embedding model: retrieval quality on your data, dimensions, input length, languages, speed and cost, open vs API models, and reading leaderboards.
- 6 min read
- Intermediate
- Reviewed
- The factors that matter when choosing an embedding model
- How dimensions translate into storage and speed
- How to use leaderboards, and why your own test matters more
- Why switching models later means re-embedding everything
Many models, different strengths
There are dozens of embedding models: from AI providers through APIs, and open models you can run yourself. They differ in quality, size, languages and price. Because every stored vector depends on the model, it is worth choosing carefully: changing later means re-embedding everything.
What to compare
| Factor | Question |
|---|---|
| Quality on your task | Does it find the right documents for your queries? |
| Dimensions | How many numbers per vector? More can mean better quality but more storage and slower search |
| Maximum input | How long a text can it embed at once? |
| Languages | Does it handle all the languages your users write in, including mixed-language queries? |
| Domain | Is it good on your kind of text: legal, medical, code, product listings? |
| Speed and cost | How fast, and how much per million tokens (or what hardware, if self-hosted)? |
| Open or API | Must data stay on your own servers? |
Dimensions and storage
Each number is usually stored as a 4-byte float. Storage grows with documents × dimensions:
def storage_gb(documents, dimensions, bytes_per_number=4):
return documents * dimensions * bytes_per_number / 1e9
print(f"{'documents':>12} {'dims':>6} {'float32':>10} {'int8':>8}")
for documents in [10_000, 1_000_000, 100_000_000]:
for dimensions in [384, 1536, 3072]:
full = storage_gb(documents, dimensions) # 4 bytes per number
small = storage_gb(documents, dimensions, 1) # 1 byte per number (quantised)
print(f"{documents:>12,} {dimensions:>6} {full:>9.2f}G {small:>7.2f}G")For a few thousand documents, size doesn't matter. At a hundred million, the difference between 384 and 3,072 dimensions is hundreds of gigabytes of fast storage, and slower searches. Quantising vectors to 1 byte per number cuts storage by four, usually with a small loss of accuracy.
Leaderboards
Public leaderboards rank embedding models on many tasks, such as retrieval, clustering and classification, across many languages. The best known is the MTEB (Massive Text Embedding Benchmark) leaderboard. Use it to build a shortlist, with the same caution as for LLM benchmarks: look at the retrieval scores for your languages, check model size and licence, and remember that a model tuned for the leaderboard may not be best on your data.
Test on your own data
The reliable way to choose:
- Collect 30 to 100 real queries, and for each, the document(s) that should come back.
- Embed your documents with each shortlisted model.
- For each query, check whether the right document appears in the top 3 or top 5 results.
- Compare the hit rates, then weigh speed, cost and storage.
Common mistakes
Shortlist an embedding model for a Hindi help centre with long articles.
# (name, dimensions, max input tokens, languages, price per million tokens)
models = [
("model-a", 1536, 8191, ["en"], 0.02),
("model-b", 1024, 32000, ["en", "hi", "te"], 0.06),
("model-c", 384, 512, ["en", "hi"], 0.00),
("model-d", 768, 8192, ["en", "hi", "ta"], 0.03),
]
# Requirements: supports Hindi ("hi") and accepts at least 2000 input tokens.
# Print the cheapest model that meets both, like: Best choice: model-x
You have chosen an embedding model and stored a million document vectors. A better model comes out. What is required to switch?
Summary
- Compare models on quality for your task, dimensions, input length, languages, domain, speed and cost, and open versus API.
- Storage grows with documents × dimensions; quantising and smaller models save a lot at scale.
- Use leaderboards such as MTEB to shortlist; decide with recall at k on your own queries.
- Switching models means re-embedding everything.
Next: building semantic search.
Finished reading? Tick it off to track your progress.