Glossary/Cosine similarity
Definition

What is cosine similarity?

Cosine similarity is a number between negative 1 and 1 that measures how aligned two vectors are. It is the dominant similarity metric in vector search because it ignores magnitude and focuses on direction, which is what semantic embeddings actually encode.

The formula

cosine(a, b) = (a · b) / (||a|| × ||b||). The dot product divided by the product of the magnitudes. A score of 1 means the vectors point the same direction. A score of 0 means they are orthogonal. A score of negative 1 means they point opposite directions.

Why not Euclidean distance

Euclidean distance is affected by vector magnitude. A long vector and a short vector can be far apart in Euclidean space even when they point the same direction. Embeddings are typically normalized to unit length so cosine and Euclidean produce the same ranking, but cosine is the canonical choice.

Interpreting scores

A useful cutoff depends on the embedding model, text, indexing method and retrieval task. Validate thresholds against examples with known relevant and irrelevant results. A similarity score is not a calibrated probability that an answer is correct.

See it working on message.com.

Unified inbox, grounded AI, flat pricing. 7-day free trial for chat and tickets. Credit card required.

Start free trial →