Worked lessons · 19 November 2026
Lesson 04 / 12 · approximately 8–12 minutes
Similarity search without the mystique
A close vector is a candidate, not a permission or a fact.
The idea
An embedding maps an item to numbers. A search system compares query and stored vectors using a selected metric. Dot product, cosine and Euclidean distance have different scaling behavior; a ranking depends on how vectors were produced and normalized. Exact nearest-neighbor search gives a useful comparison target. Approximate indexes such as HNSW or IVF trade some recall for speed or memory efficiency. Product quantization compresses representations. Changing the embedding model generally requires a compatibility and reindexing plan.
Worked example
Consider query q=(1,0), and items A=(0.9,0.1), B=(0.7,0.7), C=(-0.2,0.8). Dot products rank A, B, C. If A belongs to another customer, the system must not disclose it. If A is an obsolete policy, freshness may remove it too. A metadata field named tenant is only useful if the application enforces it. A collection name by itself does not create isolation.
Use it in a workflow
- Choose a metric compatible with the embedding representation.
- Filter by authorized scope and active revision.
- Compare exact and approximate retrieval on a fixed judged set.
- Track deletion, correction and cache invalidation as part of indexing.
Try it without a model
Compute the three dot products on paper. Then assume A is unauthorized and B is superseded. What may the answer use?
Compare with the answer criteria
Scores are 0.9, 0.7 and -0.2. A and B are excluded regardless of rank. C may be considered only if it supports the question; otherwise abstain. Never fill a quota with unauthorized or irrelevant evidence.