Embeddings and Similarity Search
Similarity search finds items whose vectors are close to the query vector.
Similarity metrics
| Metric | Meaning |
|---|---|
| cosine similarity | compares direction |
| dot product | compares direction and magnitude |
| Euclidean distance | compares geometric distance |
Many embedding systems normalize vectors, making cosine and dot product behave similarly.
Search flow
text
query text -> query embedding -> nearest vectors -> filtered results -> rerank
Metadata filters
Vector similarity alone is not enough.
Filter by:
- user permissions
- document type
- date
- product
- language
- source quality
Evaluation
Create queries with expected results. Measure whether those results appear near the top.
Knowledge check
Q1: What does cosine similarity compare?
The direction of two vectors.
Q2: Why add metadata filters?
To improve relevance and enforce permissions.