Cosine similarity and dot product give identical rankings under exactly one condition. Which is it?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
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.
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.
What an interviewer would ask next. Try answering before peeking at the approach.
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.