Skip to content
AgenticAIWiki
  1. Learn
  2. Part 1
  3. 4. Embeddings and semantic search
  4. 4.5

Lesson 4.5 · 5 of 10 · 5 min read · Reviewed 24 Nov 2026

Embedding models and dimensions

By the end, you can

  • Compare embedding models on the things that matter.
  • Pick a dimension count and know what it costs.

Two models, two jobs

A RAGRetrieval-augmented generation (RAG): Retrieving relevant documents at request time and adding them to the prompt so the answer is grounded in them. or search system usually uses two models:

Model Input Output Example job
Embedding model Text (or images) A fixed-length list of numbers Find the 5 most similar chunks
Generation model (Claude) A prompt Text Answer using those chunks

Claude doesn’t produce embeddings. The Claude docs point to dedicated embedding providers; any good embedding modelEmbedding model: A model trained to turn text (or images) into embeddings for search and comparison, rather than to generate text. works with Claude because the two only meet in the prompt.

What to compare

Factor Why it matters How to check
Retrieval quality on your data Leaderboards measure general data, not yours Build a small labelled set (26.x) and measure recall@k
Dimensions Storage, memory and search speed scale with it Model card
Max input length Longer chunks get cut off silently Model card; test with long inputs
Languages and domains Code, legal or multilingual text may need a specialised model Model card, your eval set
Query vs document modes Some models want a flag or prefix for queries vs documents Provider docs
Cost and latency You embed every chunk once, and every query live Pricing page, a timing test
Where it runs Hosted API, or a local open-weight model for data residency Your constraints (70.4)

Public benchmarks such as MTEB are a good shortlist tool. They are not a substitute for measuring on your own queries.

Dimensions in numbers

vectors x dimensions x 4 bytes (float32)

1,000,000 x   384 dims  = about 1.5 GB
1,000,000 x 1,024 dims  = about 4.1 GB
1,000,000 x 3,072 dims  = about 12.3 GB

Bigger isn’t automatically better. A well-trained 768-dimension model can beat a weaker 3,072-dimension one, and it is four times cheaper to store and search.

Shortening vectors

Some models are trained so the first numbers in the vector carry the most meaning (Matryoshka representation learningMatryoshka embeddings: Embeddings trained so that their first dimensions carry the most meaning, letting you truncate them to save space.). You can keep, say, the first 256 of 1,024 numbers, re-normalise, and lose only a little quality. That is a cheap first stage: search with short vectors, then re-rank the top 100 with full ones.

Only do this if the model’s docs say it supports it. Cutting an ordinary embeddingEmbedding: A list of numbers (a vector) that represents the meaning of a piece of text, so similar meanings land close together. loses meaning unpredictably.

Version everything

Store model, version and dimensions beside every vector. When you change any of them:

  1. Build a new index alongside the old one.
  2. Re-embed all documents into it.
  3. Compare retrieval quality on your evalEval: A repeatable test that measures how well an AI system performs on a set of cases with defined success criteria. set.
  4. Switch queries over, then delete the old index.

Never mix vectors from two models in one index. Similarities between them are meaningless, and nothing will throw an error to warn you.

Key points

  • An embedding model is a separate model from the chat model; Claude itself doesn't return embeddings, so you pair it with an embedding provider.
  • Dimensions are the length of each vector. More dimensions can hold finer meaning but cost more storage and slower search.
  • Some models are trained so you can cut vectors shorter (Matryoshka-style) and keep most of the quality.
  • Vectors from different models, or different versions, can't be compared. Changing model means re-embedding everything.
Hands-on labRuns in the Playground

Size a vector index before building it

Work out storage for different dimensions and precisions, and pick a setup that fits a memory budget.

You will have: A sizing table and a recommended configuration for 10 million chunks under a 30 GB budget.

Steps

  1. Run the starter: the table prints zeros.
  2. Fill in size_gb(): vectors times dimensions times bytes per number, in GB.
  3. Print the table for 384, 768, 1,024 and 3,072 dimensions at float32, int8 and binary.
  4. Pick the largest float32 option that fits 30 GB, and note what int8 would allow.
  5. Add a 20% allowance for index overhead and check your pick still fits.

Done when

  • 1,024 dims at float32 for 10 million vectors prints 41.0 GB.
  • The recommendation fits within 30 GB including overhead.
  • The script prints 'pick: 384 dims float32'.

Open in the Playground No API key needed.

Starter code (Python)
N = 10_000_000
BUDGET_GB = 30
BYTES = {"float32": 4, "int8": 1, "binary": 1 / 8}

def size_gb(n, dims, bytes_per):
    return 0.0  # TODO: n * dims * bytes_per, converted to GB (divide by 1e9)

for dims in [384, 768, 1024, 3072]:
    row = [f"{p}={size_gb(N, dims, b):.1f}GB" for p, b in BYTES.items()]
    print(dims, "dims:", ", ".join(row))
# TODO: find the largest float32 option where size * 1.2 (overhead) <= BUDGET_GB and print "pick: ..."
Show a solution
N = 10_000_000
BUDGET_GB = 30
BYTES = {"float32": 4, "int8": 1, "binary": 1 / 8}

def size_gb(n, dims, bytes_per):
    return n * dims * bytes_per / 1e9

for dims in [384, 768, 1024, 3072]:
    row = [f"{p}={size_gb(N, dims, b):.1f}GB" for p, b in BYTES.items()]
    print(dims, "dims:", ", ".join(row))
fits = [d for d in [384, 768, 1024, 3072] if size_gb(N, d, 4) * 1.2 <= BUDGET_GB]
print(f"pick: {max(fits)} dims float32" if fits else "pick: none at float32")
int8 = [d for d in [384, 768, 1024, 3072] if size_gb(N, d, 1) * 1.2 <= BUDGET_GB]
print(f"with int8 you could afford up to {max(int8)} dims")
Quick checkYou switch to a newer embedding model. What must happen to the vectors already in your index?
How sure are you?
Pick an answer and how sure you are