Skip to content
AI360XpertBeta
Glossary
Definition

Unit Vector

A vector of length exactly one, carrying direction with no magnitude.

Think of It Like This

Like a compass needle: pointing you in an exact direction while always remaining exactly two inches long.

Any nonzero vector becomes a unit vector when divided by its own L2 norm: v^=v/∥v∥2\hat{v} = v / \lVert v \rVert_2. 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.