Unit Vector
A vector of length exactly one, carrying direction with no magnitude.
Any nonzero vector becomes a unit vector when divided by its own L2 norm: . The direction survives, the length is discarded.
This one line is the fix for the most common retrieval bug there is. Raw dot products rank partly by vector length, so long embeddings win regardless of relevance — and embedding length is usually an artifact of training rather than a meaning worth ranking by. Normalise every vector once at write time and the dot product becomes cosine similarity, so you get direction-only comparison at dot-product speed. That is why vector databases store normalised embeddings.
The one thing to remember is that the zero vector has no direction, so it cannot be normalised. Guard the division.