Concept guide · Embeddings and vector search
What is approximate nearest-neighbour search?
A slower explanation for when the short interview answer is not enough. Start with the intuition, then connect it to the technical idea and the way an interviewer expects you to reason about it.
ML area
Generative AI → Approximate nearest-neighbour search
Interview format
Advanced · Scenario
Question
GENAI-038
Start with the idea
In simple terms
Exact search compares a query with every stored vector. Approximate nearest-neighbour search uses an index to inspect a much smaller part of the collection, trading a little recall for speed and scale.
Make it concrete
Searching ten million document chunks by brute force may be too slow for an interactive assistant, while an ANN index can find a strong candidate set quickly.
Build the answer
How to approach it
- 1Define the exact-search baseline and the recall target.
- 2Choose an index family based on scale, updates, filters, and memory.
- 3Tune only after measuring recall and tail latency on real queries.
Go one level deeper
The technical explanation
ANN is not a single algorithm. Graph, inverted-file, and quantised indexes make different memory, build-time, update, and recall trade-offs. Tune against a deployment-like workload: measure recall against an exact baseline, p95 latency, memory, index construction time, and filtered-query behaviour. A faster retriever that misses the evidence needed for an answer may make the whole system worse.
Say this in the interview
Approximate nearest-neighbour search trades a small amount of exactness for much lower latency at scale. Indexes such as graph- or cluster-based structures reduce the candidates that must be compared. Tune recall, latency, memory, build time, and update behaviour together.
Keep preparing