Cosine similarity measures the angle between two vectors. It returns a value from -1 to 1: 1 means they point in exactly the same direction, 0 means they are perpendicular (no relationship), and -1 means they point in opposite directions.
Cosine similarity is invariant to vector magnitude. A short sentence and a long paragraph about the same topic produce vectors of different lengths, but their cosine similarity can still be high if they point in the same semantic direction. Euclidean distance would incorrectly penalize the length difference.
Cosine similarity = (A · B) / (|A| × |B|)
The dot product (A · B) sums the products of corresponding dimensions — measuring raw agreement. Dividing by the magnitudes normalizes this to a -1 to 1 scale regardless of how long the vectors are.
0.85–1.0 — Near-identical semantic content. Same sentence rephrased, same fact stated differently.
0.6–0.85 — Related topics in the same domain. Semantically connected but not saying the same thing.
Below 0.3 — Unrelated content. Different topics with no semantic connection.
These thresholds vary by embedding model and domain. Always test on your actual data rather than applying universal cutoffs.
If all embedding vectors are normalized to unit length (magnitude = 1), the raw dot product equals cosine similarity. Many production systems pre-normalize embeddings before storage, making dot product and cosine similarity computationally identical — while dot product is slightly faster to compute.
Ask the AI assistant about cosine similarity, the dot product, or how to interpret similarity scores.