Back to Home
Embeddings & Search
Distance vs Similarity
Distance tells how far apart two items are. Similarity tells how alike they are.
This is a simple learning demo using small vectors, not real AI embeddings.
Interactive Playground
Query vector
[ ]
Item A vector
[ ]
Item B vector
[ ]
Statistics
cat
Query
Closest by Distance
Most Similar by Cosine
Item A Distance
Item B Distance
Which Metric to Use?
📐
Cosine Similarity
0 → 1
Measures the angle between vectors. Best for comparing meaning regardless of text length.
📏
Euclidean Distance
0 → ∞
Measures straight-line distance between points. Smaller = more similar.
✖️
Dot Product
-∞ → ∞
Combines angle + magnitude. Fast to compute, used inside neural networks.
2D Vector Map
Euclidean Distance
(lower = closer)
Item A
dog
Item B
car
Cosine Similarity
(higher = more alike)
Item A
dog
Item B
car
🎓
Tips
2 tips
They usually agree, but not always. Two long documents can have the same direction (high cosine similarity) yet be far apart in space (high Euclidean distance).
Use cosine for text embeddings, it's length-insensitive, so a tweet and a paragraph about the same topic still score high.
💡
Key Takeaway
Close distance and high similarity often point to the same result, but they are not the same idea. Distance measures space; similarity measures angle.