Embeddings Cheat Sheet

Dimensions, distance metrics, and the normalisation everyone forgets

An embedding turns text into a point in space so that "close" means "similar". Everything else is choosing the space and the ruler.

Intermediate 1 min read 10 Entries Version 1.0 Sabir Updated 1
Download PDF Export Markdown Export HTML

Distance metrics

Metric Measures Use when
Cosine Angle only, ignoring magnitude Text similarity — the usual choice
Dot product Angle and magnitude together Vectors are already normalised (then it equals cosine)
Euclidean (L2) Straight-line distance Coordinates and non-normalised spaces
Manhattan (L1) Axis-aligned distance Rare for text; robust to outliers

Rules

  • Embed the query and the documents with the SAME model Two models produce two unrelated spaces; similarity between them is noise
  • Re-embed everything when you change model There is no migration path — the space itself changed
  • Normalise if your store uses dot product Otherwise long documents win on magnitude alone
  • Store the raw text next to the vector You cannot reconstruct text from an embedding
  • More dimensions is not automatically better It costs memory and index time for often marginal recall
  • Test whether hybrid search beats pure vectors Keyword matching still wins on names, codes and IDs

Similarity is not relevance

A chunk that says "we do not offer refunds" is highly similar to the query "how do I get a refund". Cosine similarity measures topic, not answerhood. That is what a reranking pass is for — and why a top-k of 5 fed blindly into a prompt so often produces a confidently wrong answer.

Frequently asked questions

Can I mix embedding models?
No. Two models produce two unrelated spaces, so similarity computed across them is noise. Changing model means re-embedding everything; there is no migration path.
Why does search return the opposite of what I asked?
Cosine similarity measures topic, not answerhood — "we do not offer refunds" is highly similar to "how do I get a refund". That gap is what a reranking pass exists to close.

Was this cheat sheet useful?

Comments

No comments yet — be the first.

Keep going

More cheat sheets

Browse all
Need a different cheat sheet? Tell us what you would like to see and we will build it — free.
Request a cheat sheet