Length & normalization·5 min
Why we normalize embeddings
0 / 1
A raw dot product mixes two things: how aligned the vectors are, and how long they are. For search we only care about alignment — a long doc shouldn't beat a short one just for being long. The fix: normalize every vector to length 1 (divide by its norm). Then the dot product is purely the angle.
Normalized vectors live on the unit sphere
Every normalized vector sits on the unit circle (sphere in 64-D)
↑ all normalized vectors
• sit on this circle (sphere in 64-D);
• • comparing them = comparing directions only
•
The corpus is already normalized
The embedding model L2-normalizes its output, so every vector in corpus_emb.f32 already has norm ≈ 1.0 (you saw doc 0 ≈ 1.0 in setup). That's not an accident — it's what makes the next "aha" possible.