No history yet

what is cosine similarity

Welcome! I would love to help you master cosine similarity. It is a incredibly elegant concept that is used everywhere from search engines to recommending your next favorite movie.

Before we dive into the details, I want to make sure I tailor this explanation perfectly to your style. Could you tell me a little bit about your background? For example, are you already comfortable with concepts like or the , or would you prefer a highly visual, conceptual introduction to start with?

I prefer a conceptual, visual introduction without heavy math.

Since you prefer a visual, concept-first approach, let's skip the math formulas for now and focus on how this works in geometric space.

Imagine we want to compare what two books are about. In modern AI, we translate the "meaning" of these books into arrows called that point in specific directions in a massive, multi-dimensional space. To find out how similar the books are, we simply look at the angle between their arrows.

Two vectors originating from the origin on a coordinate grid, with an arc highlighting the angle between them and its cosine similarity value.

As you can see in the diagram, when the two arrows point in the exact same direction, the angle between them is zero. In the world of cosine similarity, this is a perfect match, which we represent with a score of 1. If you rotate one arrow so it is perpendicular to the other (forming a 90-degree angle), they share no relationship at all, giving us a score of 0. And if they point in completely opposite directions, they are as different as possible, resulting in a score of -1.