Learn AI Math

Cosine Similarity

What is Cosine Similarity?

In one sentence: Cosine similarity measures how similar two vectors are by checking the angle between them.

If two vectors point in the same direction, the score is close to 1. If they point at right angles, it is 0. If they point in opposite directions, it is −1. It ignores how long the vectors are and focuses on direction, which works well for meaning.

Σ Quick math / rule of thumb: cos(θ) = (A · B) ÷ (‖A‖ × ‖B‖). Scores run from −1 (opposite direction) through 0 (unrelated) to +1 (same direction).

What does Cosine Similarity look like?

The embeddings for "happy" and "joyful" might have a cosine similarity of 0.9.

Why does Cosine Similarity matter?

It is the most common way to compare embeddings.

Last updated · Fact-checked by The AI Math

Linking to this page from a lesson or article?

Like this explanation? Get one every week.

The AI Math newsletter turns confusing AI news into plain English. No hype, no jargon walls.