
Explain like I'm five
Imagine you and a friend each have a list of favorite fruits, but you rate them on a scale of 1 to 5. Cosine similarity checks if you both like the same fruits in the same order—like if you both love bananas more than apples—even if one of you gives higher numbers overall. It’s like comparing the direction of your tastes, not how strongly you feel.

Why it matters
It’s essential in AI for comparing things like documents or user preferences without being thrown off by scale (e.g., one person uses 1-5 ratings, another uses 1-10). You encounter it in search engines, recommendation systems, and text analysis.

Common misconception
People often think cosine similarity measures the distance between points, but it actually measures the angle between vectors—so two vectors pointing the same way get a score of 1, even if one is much longer. This means it ignores magnitude, which is both its strength and a potential pitfall.

Formal definition
Cosine similarity is a measure of similarity between two non-zero vectors in an inner product space, defined as the cosine of the angle between them. It equals the dot product of the vectors divided by the product of their magnitudes, yielding a value between -1 and 1. A value of 1 indicates identical direction, 0 indicates orthogonality, and -1 indicates opposite direction.