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.

Category: RAG Difficulty: Intermediate Version: 1.0 Updated: February 3, 2026 Author: Sabir

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

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.

FAQs

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.