The idea
Key formulas
Cosine similarity
Angle interpretation
Loading lessons…
Just a moment, getting everything ready. The first load can take up to a minute.
Linear algebra
Cosine similarity compares vector direction, so changing either vector’s positive scale does not change the score.
For nonzero vectors and , cosine similarity is the cosine of their angle:
It ranges from (opposite directions) through (orthogonal) to (same direction). Zero vectors have no direction, so their cosine similarity is undefined; this demo displays zero as a neutral fallback.