Available Distance Metrics
Qdrant supports four distance metrics:Cosine Similarity
Measures the angle between vectors, ignoring magnitude:- Normalized: Vector magnitude doesn’t affect similarity
- Order: Higher scores are better (maximization)
- Symmetric: cosine(A, B) = cosine(B, A)
Cosine is the most common metric for semantic search and text embeddings. Most embedding models (OpenAI, Cohere, Sentence Transformers) are optimized for cosine similarity.
When to Use Cosine
✅ Use Cosine when:- Working with text embeddings (BERT, GPT, etc.)
- Your embedding model outputs normalized vectors
- You care about direction, not magnitude
- Using pre-trained models (OpenAI, Cohere, etc.)
- Vector magnitude contains important information
- Your model was specifically trained for Euclidean distance
Example: Text Similarity
Euclidean Distance (L2)
Measures straight-line distance between vectors:- Magnitude-sensitive: Vector length affects distance
- Order: Lower scores are better (minimization)
- Symmetric: euclid(A, B) = euclid(B, A)
Euclidean distance considers both direction and magnitude. It’s commonly used for image embeddings and when vector magnitude is meaningful.
When to Use Euclidean
✅ Use Euclidean when:- Vector magnitude is meaningful
- Working with image embeddings (ResNet, EfficientNet)
- Your model was trained with Euclidean distance
- You need geometric distance in embedding space
- Vectors have inconsistent magnitudes
- You only care about direction
Example: Spatial Distance
Dot Product
Computes the product of corresponding elements:- Unnormalized: Magnitude matters significantly
- Order: Higher scores are better (maximization)
- Symmetric: dot(A, B) = dot(B, A)
- Efficient: Fastest to compute
When to Use Dot Product
✅ Use Dot Product when:- Your vectors are pre-normalized
- Working with binary or categorical features
- Your model was specifically trained for dot product
- Maximum computational efficiency is needed
- Vectors have inconsistent magnitudes
- You need normalized similarity scores
Relationship with Cosine
For normalized vectors (||v|| = 1), dot product equals cosine similarity:Manhattan Distance (L1)
Sum of absolute differences:- Axis-aligned: Measures distance along axes
- Order: Lower scores are better (minimization)
- Symmetric: manhattan(A, B) = manhattan(B, A)
- Robust: Less sensitive to outliers than Euclidean
When to Use Manhattan
✅ Use Manhattan when:- Your features are independent/axis-aligned
- You want robustness to outliers
- Working with grid-like data
- Your model was trained with Manhattan distance
- Most embedding models (rarely optimized for L1)
- You need standard semantic similarity
Manhattan is less common in vector search but useful for specialized applications where features are independent.
Score Ordering
| Metric | Better Score | Range |
|---|---|---|
| Cosine | Higher (maximize) | -1 to 1 |
| Euclidean | Lower (minimize) | 0 to ∞ |
| Dot Product | Higher (maximize) | -∞ to ∞ |
| Manhattan | Lower (minimize) | 0 to ∞ |
Qdrant automatically handles score ordering. Top results always represent most similar vectors regardless of metric.
Common Embedding Models
Match your distance metric to your model:| Model | Dimensions | Distance |
|---|---|---|
| OpenAI text-embedding-3-small | 1536 | Cosine |
| OpenAI text-embedding-3-large | 3072 | Cosine |
| Cohere embed-english-v3.0 | 1024 | Cosine |
| Cohere embed-multilingual-v3.0 | 1024 | Cosine |
| Sentence Transformers (all-MiniLM-L6-v2) | 384 | Cosine |
| Sentence Transformers (all-mpnet-base-v2) | 768 | Cosine |
| CLIP ViT-B/32 | 512 | Cosine |
| ResNet-50 | 2048 | Euclidean |
| BGE-large-en-v1.5 | 1024 | Cosine |
| E5-large-v2 | 1024 | Cosine |
Performance Comparison
| Metric | Computation Speed | Memory | Use Case |
|---|---|---|---|
| Dot Product | Fastest | Lowest | Pre-normalized vectors |
| Cosine | Fast | Medium | General semantic search |
| Euclidean | Medium | Medium | Image embeddings |
| Manhattan | Medium | Medium | Specialized applications |
Threshold Filtering
Set minimum similarity thresholds:Choosing the Right Metric
Decision Flow
- Check your model’s documentation - Use the recommended metric
- Are vectors normalized?
- Yes → Use Dot Product (fastest) or Cosine (more intuitive)
- No → Continue to step 3
- Does magnitude matter?
- No → Use Cosine
- Yes → Use Euclidean
- Special requirements?
- Need outlier robustness → Manhattan
- Maximum speed → Dot Product (with normalization)
Quick Reference
For text embeddings (default)
For text embeddings (default)
Use Cosine. Nearly all text embedding models are optimized for cosine similarity.
For image embeddings
For image embeddings
Use Euclidean or Cosine. Check your model’s documentation. ResNets often use Euclidean, CLIP uses Cosine.
For maximum speed
For maximum speed
Use Dot Product if your vectors are pre-normalized. It’s computationally cheaper than Cosine.
For normalized vectors
For normalized vectors
Use Dot Product. It’s equivalent to Cosine but faster.
Vector Normalization
Normalize vectors for consistent Cosine/Dot Product behavior:Many embedding models (OpenAI, Cohere) return pre-normalized vectors. Check before normalizing!
Best Practices
Always use your model's recommended metric
Always use your model's recommended metric
Embedding models are trained with specific metrics. Using a different metric will degrade results.
Normalize vectors when using Dot Product
Normalize vectors when using Dot Product
Dot Product is sensitive to magnitude. Normalize vectors first unless magnitude is meaningful.
Test with your actual data
Test with your actual data
Benchmark different metrics with your queries to find what works best in practice.
Consider Dot Product for speed
Consider Dot Product for speed
If using Cosine with normalized vectors, switch to Dot Product for better performance.
Be consistent
Be consistent
Use the same metric for indexing and querying. Mixing metrics will produce incorrect results.
Related Concepts
Collections
Learn how to configure distance metrics in collections
Vectors
Understand vector types and preprocessing
Indexing
Explore how HNSW indexes work with distance metrics
Points
Learn how points store vectors for comparison