- The metric determines which candidates are considered “close” and therefore returned to downstream systems.
- Embedding generation (model architecture, normalization) often dictates which metric is appropriate.
- Wrong choices can yield results that are numerically close but semantically irrelevant.
- Intuition: measures the angle between two vectors and ignores their magnitudes. Vectors pointing in the same direction are similar regardless of length.
- Formula:
cosine(u, v) = (u · v) / (||u|| ||v||) - Range:
-1to1(1= same direction,0= orthogonal/unrelated,-1= opposite). - When to use: ideal for text embeddings and semantic search where topic/ direction matters more than length. Short and long texts about the same topic can still be similar.
- Typical usage: commonly used with text embedding services such as OpenAI embeddings and supported by vector databases like Pinecone.
- Intuition: the straight-line distance between two points in vector space (like measuring with a ruler). It depends on magnitude.
- Formula:
euclidean(u, v) = ||u - v|| - Range:
0to∞(0= identical vectors; larger values = more distant). - When to use: appropriate when absolute magnitude encodes important information, for example in some image similarity tasks, sensor measurements, or anomaly detection where vector length represents intensity or scale.
- Typical usage: supported by vector databases such as Weaviate and often used in computer vision scenarios.
- Intuition: combines direction and magnitude — it measures alignment while scaling by vector lengths.
- Formula:
dot(u, v) = Σ u_i * v_i - Range:
-∞to+∞(unbounded). - When to use: useful when both direction and magnitude matter, for example recommendation systems where raw model outputs (scores) are meaningful and should affect ranking.
Practical tip: if you normalize all vectors to unit length, the dot product becomes equivalent to cosine similarity. Normalization is common when you want to remove magnitude and compare only direction.
| Metric | Intuition | Numeric range | Use cases | Common tools |
|---|---|---|---|---|
| Cosine similarity | Angle between vectors; ignores length | -1 to 1 | Text/semantic search, when topic matters over length | OpenAI embeddings, Pinecone |
| Euclidean distance | Straight-line distance; uses magnitude | 0 to ∞ | Vision tasks, sensor intensity, anomaly detection | Weaviate, FAISS |
| Dot product | Alignment weighted by magnitude | -∞ to +∞ | Recommenders, when magnitudes encode signal | Model scoring, ANN libraries |
- If you care only about semantic direction/topic and want to ignore length differences, use cosine similarity (or normalize vectors and use dot product).
- If absolute magnitude encodes meaningful signals (intensity, confidence, energy), prefer Euclidean distance or unnormalized dot product.
- Use dot product when the model’s raw outputs (magnitudes) should directly influence ranking or scoring.

- OpenAI Embeddings Guide
- Pinecone Vector Database
- Weaviate Vector Search
- FAISS — Facebook AI Similarity Search
- Milvus — an open-source vector database