Skip to main content
Back to Blog

Similarity search, finding neighbors on the meaning map

Ria places a query card into the map drawer. A flat exact baseline measures every stored vector.

Fernando Torres

CEO & Cofounder, Memori · Stanford GSB MSx ’26 ·

Ria places a query card into the map drawer. A flat exact baseline measures every stored vector. A second route follows an approximate index toward a smaller candidate set.

Embeddings are model-produced vector representations whose useful geometry depends on the task. Relevance scoring ranks candidates under a chosen signal. A higher score is evidence, not proof of usefulness.

Ria places an orange query point among many stored points on the map-drawer grid.
Panel 1 transcript: Ria: "First, the query is embedded in the same space as the stored items."
A flat-search measuring line touches every point in sequence while Ava watches a clock.
Panel 2 transcript: Ria: "A flat exact baseline scores every stored vector." Ava: "That finds the nearest under the metric, but the scan grows with the collection."
Ria opens an indexed route that reaches a compact group of promising candidates instead of every point.
Panel 3 transcript: Ria: "Approximate search uses an index to inspect a promising subset."
A nearby point outside the chosen subset remains faintly visible as Ava points to it.
Panel 4 transcript: Ava: "So it is faster, but it can miss a true nearest neighbor." Ria: "Yes. We tune recall against latency and memory."
Ria presents a ranked candidate tray with a small evaluation checklist beside it.
Panel 5 transcript: Ria: "Nearest is an estimate of similarity, not a guarantee of relevance or truth."

Problem: A flat or brute-force exact baseline scores every stored vector, which can be too slow for an interactive system at large scale.

Resolution: The reader learns the difference between exact nearest-neighbor search and approximate nearest-neighbor search, including the latency, memory, and recall tradeoff.

Flat exact baseline and approximate neighbor search. Split the diagram into a flat exact lane and an approximate lane. The flat lane touches every vector.

A flat exact baseline scores the full collection. Approximate search visits a smaller candidate set. Speed comes with recall and memory tradeoffs, and nearest does not automatically mean relevant.

A flat exact search defines the baseline

A flat or brute-force exact implementation computes the chosen similarity or distance between the query and every stored vector, then ranks the results. It returns the true nearest items under that metric. Other exact methods may use structure or bounds to avoid some comparisons without becoming approximate. None of these methods proves that the representation or metric matches the user's intent.

The baseline is valuable even when it is too slow for the final system. On a manageable evaluation set, exact results provide a reference against which an approximate index can be measured. If the index returns a different top ten, the team can identify which neighbors were lost rather than guessing whether the shortcut changed anything.

Exact also has a precise limit. It guarantees nearest under the selected vectors and metric, not best answer, freshest document, or authorized source. A perfectly computed neighbor can still be an obsolete draft. Retrieval quality includes representation, filtering, provenance, and downstream validation in addition to search accuracy.

Indexes make a practical estimate

Approximate nearest-neighbor systems organize vectors so a query can visit a promising subset. This can reduce latency dramatically, but an index may fail to include one of the exact nearest items. Recall measures how often the desired neighbors survive that shortcut.

Different index families choose the subset differently. A partitioned index routes the query toward selected regions. A graph-based index navigates links among nearby items. Compressed codes reduce memory or comparison cost. These are design families, not a universal sequence every product follows.

Approximation can be tuned. Searching more partitions, exploring more graph candidates, or reranking a larger set may recover neighbors at the cost of time and work. That makes the tradeoff measurable rather than mysterious: change one setting, hold the judged queries constant, and compare recall with latency and memory.

Tune for the query mix

Index settings trade recall, latency, memory, build time, and update cost. The right setting comes from representative queries and relevance judgments. Candidate retrieval can also be followed by filtering or reranking before anything reaches a response.

Average latency alone can hide a bad tail. A setting that is fast for common queries may slow sharply under a selective permission filter or after many updates. Measure high-percentile latency, index freshness, rebuild time, and behavior when candidates are removed as well as the clean demo path.

Finally, evaluate the misses. If the omitted exact neighbor is interchangeable with the returned result, lower recall may be acceptable. If it is the only current policy or the only document the user may access, the same miss is serious. Recall has meaning only in the context of the query mix and consequences.

Glossary

Similarity search
Ranking candidates by a chosen similarity or distance rule. | Office analogy: Ria compares the query card with stored coordinate cards.
Nearest-neighbor search
Finding the closest items under the selected representation and metric. | Example: The nearest item is a candidate, not proof that it is relevant or true.
Exact nearest-neighbor search
A search that returns the true nearest items under a selected metric. A flat or brute-force implementation scores every stored vector. Other exact methods may prune comparisons without accepting approximation.
Approximate nearest-neighbor search
An indexed search that visits a subset to reduce work, accepting the possibility of missed exact neighbors.
Recall
Here, the share of desired exact neighbors recovered by the approximate search. | Example: Recovering nine of ten exact neighbors gives 90 percent recall for that evaluated query.

Try it yourself

  1. Predict the tradeoff before measuring: if the search visits fewer candidates, what might improve, and what relevant neighbor might it miss?
  2. Measure recall and latency on representative queries before changing index settings.
  3. Inspect false positives and missed neighbors. A fast top result can still be irrelevant.

Next episode

Next: measure how two nonzero vectors align by direction.