Cosine Similarity, Dot Product and Euclidean Distance: Choosing a Metric
Compare cosine similarity, dot product, and Euclidean distance for vector search, and learn when each metric is the right choice.
Published on • November 22, 2026
AI Assistant

Introduction
Every vector search needs a distance metric — the rule that decides how “close” two vectors are. The three you will meet constantly are cosine similarity, dot product, and Euclidean distance. They are related, but they are not interchangeable. Picking the wrong one quietly degrades recall.
The Three Metrics
Cosine similarity
Measures the angle between two vectors, ignoring their lengths:
cosine(a, b) = (a · b) / (||a|| × ||b||)
- Range: -1 to 1 (0 = orthogonal, 1 = identical direction)
- Only cares about direction
- The default for most text-embedding models
Dot product
dot(a, b) = a · b = Σ aᵢbᵢ
- Sensitive to both direction and magnitude
- Equals cosine × both magnitudes
- The natural metric for models trained with it (e.g., some recommendation and multimodal models)
Euclidean distance (L2)
L2(a, b) = sqrt(Σ (aᵢ - bᵢ)²)
- Straight-line distance between points
- Sensitive to magnitude and direction
- Intuitive; corresponds to distance in physical space
How They Relate
For unit-normalized vectors (length 1):
- Dot product equals cosine similarity
- Euclidean distance is a monotonic transform of cosine:
L2² = 2 − 2·cosine
So if all your vectors are normalized, the three metrics produce the same ranking. The differences only appear when magnitudes vary.
Choosing a Metric
| Situation | Recommended metric |
|---|---|
| Text embeddings (SBERT, OpenAI, Cohere) | Cosine |
| Vectors where length carries signal (e.g., magnitude = popularity) | Dot product |
| Low-dimensional, spatial, or clustered data | Euclidean |
| You don’t know the model’s training metric | Match the model card — this matters most |
The golden rule: use the metric your embedding model was trained with. Model authors tune representations for a specific objective; evaluating with a different metric can cut recall noticeably.
Practical Checklist
- Check the model documentation for its recommended metric.
- If you normalize vectors, cosine and dot product become equivalent — pick whichever your database optimizes.
- Benchmark: run your own eval set under each metric and compare recall@k before committing.
Conclusion
Cosine, dot product, and Euclidean distance are three lenses on the same question: how close are these vectors? For unit-length text embeddings they agree; for everything else, follow the metric your model was trained on and verify with a benchmark.