01Similarity depends on geometry
Cosine compares direction, dot product includes magnitude, and Euclidean measures straight-line distance. If vectors are normalized, cosine and dot-product ranking align. Use the metric expected by the embedding/index setup.
An embedding model places inputs in a learned vector space. Similarity depends on what the model was trained to make nearby, so two equally sized vectors from different models do not automatically share meaningful coordinates. Use compatible encoders and the intended metric. Semantic proximity can help retrieve candidates, but a nearby document may contradict the query or lack the decisive detail.
Cosine similarity divides the dot product by both vector norms. For unit vectors [1,0] and [0.8,0.6], the dot product and cosine are 0.8. Without normalization, vector magnitude changes dot-product ranking. A similarity of 0.8 is not an 80% probability of relevance. Set thresholds using labeled task data and examine hard negatives such as similar wording with the wrong account or policy version.
- Thresholds are dataset-specific
- Nearest does not mean correct
- Domain language can shift neighborhoods
02ANN trades exactness for speed
Scanning every vector is simple but expensive at large N. Approximate nearest-neighbor indexes prune the search space, trading memory, build/update cost, and some recall for latency.
Exact search compares the query with every candidate and gives a useful baseline on a small corpus. At large scale, approximate nearest-neighbor indexes avoid many comparisons using structures such as navigable graphs or compressed partitions. Increasing search effort often improves recall at a latency cost; memory and index build/update cost also matter. Measure the frontier on your data.
Distinguish ANN recall from task retrieval quality. An approximate index can accurately reproduce the nearest vectors while the embedding model ranks irrelevant documents highly. Conversely, a good representation can be harmed by aggressive index approximation. Compare exact vector search first, then ANN, then downstream answer quality so you know which layer caused a regression.
- Tune recall vs latency empirically
- Filter strategy affects index performance
- Deletes and model upgrades require lifecycle plans
03Embeddings are reusable features
Beyond search, vectors support clustering, nearest-neighbor classification, recommendations, anomaly hints, and duplicate detection. For final decisions, combine them with labels, rules, and evaluation.
The same vectors can support nearest-neighbor classification, clustering, recommendations, and duplicate detection, but each task needs its own evaluation. Similarity useful for recommendations may be too loose for identifying duplicate legal clauses. Include identifiers, negation, domain jargon, and multilingual examples when those occur in production. Preserve metadata constraints alongside vector features.
An embedding upgrade is a data migration. Re-encode documents with the compatible new model, build a new index, compare query results and operational cost, then switch traffic gradually. Keep the old index for rollback until the new one is validated. Coordinate streaming updates and deletions during the overlap so a newly built index does not silently resurrect removed documents.
- Use hard negatives that look deceptively similar
- Version embedding model with the index
- Re-embed or dual-index during migrations