Complete the identity: when do dot product and cosine coincide?
Dot product equals cosine exactly when both vectors are L2-normalized to unit length, because the cosine denominator collapses to 1.
Imagine the cosine formula has a fraction with the dot product on top and a 'length stuff' on the bottom. If both vectors have length one, the bottom of the fraction is one times one, which is just one. Dividing by one does nothing, so what is left is exactly the dot product. The whole point of normalization is to make that fraction disappear so the cheap operation (dot product) replaces the expensive one (cosine) at no quality cost.
Detailed answer & concept explanation~3 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.
5-7 min: state the identity + derive via cosine formula + production implications + normalization invariant + quantization caveat.
Real products, models, and research that use this idea.
- OpenAI text-embedding-3 returns L2-normalized vectors by default.
- FAISS IndexFlatIP is the recommended index type for normalized vectors and runs faster than IndexFlatL2.
- Pinecone auto-detects normalized input and routes cosine queries through the dot-product path.
- sentence-transformers normalize_embeddings=True is the standard production flag.
What an interviewer would ask next. Try answering before peeking at the approach.
QIf two vectors share an arbitrary common norm c (not just 1), does the identity generalize?
QWhy might quantization drift the norm and how do you handle it?
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.
Writing the answer as 'unit vectors' without realizing both vectors must share unit norm, not just one of them.
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.