Skip to content
BENIBIX Learn

Cosine Similarity

Also known as Cosine Distance, Cosine Score

A score that says how alike two vectors are, by their angle.

Think of it like

Think of it like two arrows. If they point the same way, the things they stand for are alike.

Example

Lucy compares 'cheap flights' with 'low-cost air travel' and gets 0.89. With 'chocolate cake' she gets 0.12.

Why it matters

It is the number behind most AI search. It decides which texts count as close.

Definition

Cosine similarity measures how alike two vectors are by the angle between them, not their length. The score runs from 1, pointing the same way, through 0, at right angles, to minus 1, pointing opposite ways. For embeddings, a higher score means closer meaning. It is the most common way to compare embeddings in search. When vectors are scaled to length 1, it gives the same result as the dot product.
The smaller the angle between two arrows, the higher the score.

Common mistake

Reading a score as a percent of sameness. A score of 0.8 does not mean 80 percent the same, and good cut-offs differ by model.

Key takeaways

  1. 1
    Angle, not length. Direction is what counts.
  2. 2
    From 1 to minus 1. Higher is closer.
  3. 3
    Cut-offs vary. Each model has its own.

Compare