Cosine and dot product produce identical rankings if and only if all vectors are L2-normalized. The norm denominator becomes 1 and cosine reduces to dot product.
Imagine two arrows on a piece of paper. The angle-only score (a measure of how parallel the two arrows are, regardless of length) cares only about the direction. The angle and length score (a measure that multiplies and adds the matching coordinates of the two arrows) cares about both: a long arrow pointing in roughly the right direction can outscore a short arrow pointing in exactly the right direction. If you first stretch or shrink every arrow to be the same length (one unit), then length stops mattering and the two measures agree perfectly. That is why modern meaning-vector models output unit-length lists by default: you get angle-only behaviour but you compute the cheaper coordinate-multiply score.
Detailed answer & concept explanation~4 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: cosine and dot product definitions, the L2-normalization equivalence, the SIMD cost argument, and the 2026 embedding model conventions.
| Property | Dot product | Cosine similarity |
|---|---|---|
| Formula | u · v | (u · v) / (||u|| · ||v||) |
| Sensitive to magnitude? | Yes | No |
| Compute cost | 1 SIMD reduction | Dot + 2 sqrt + 1 div |
| Identical ranking with the other when? | All vectors unit norm | Always |
| Production preference for normalized embeddings | Yes (cheaper) | Redundant |
| Risk if embeddings are un-normalized | Length bias | None |
Real products, models, and research that use this idea.
- OpenAI text-embedding-3-small and text-embedding-3-large return L2-normalized vectors, so dot product gives cosine semantics for free.
- Cohere embed-v3 ships normalized embeddings; the Cohere documentation explicitly recommends dot-product indexes for cost.
- BAAI's BGE family normalizes by default; this is what enables their billion-scale retrieval benchmarks to use dot-product indexes.
- Pinecone, Qdrant, and Weaviate all accept either 'cosine' or 'dotproduct' as a metric choice; for normalized embeddings they produce identical rankings.
- pgvector exposes three operators (`<->` for L2, `<#>` for negative dot product, `<=>` for cosine) and recommends `<#>` for normalized embeddings.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you detect that an embedding model is silently returning un-normalized vectors in production?
QWhy does pgvector expose three separate distance operators?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Claiming dot product and cosine are always equivalent. They are equivalent only when all vectors have unit L2 norm; otherwise dot product is biased toward longer vectors.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.