Jargonautica
Retrieval and Knowledge

Approximate Nearest Neighbour Search

Also called: ANN Search

A way of finding the items most similar to a query very quickly by accepting that the answer will occasionally miss the very best match. When text or images are turned into lists of numbers, finding the closest ones exactly means comparing against everything, which is too slow for millions of items. Approximate methods trade a little accuracy for answers in milliseconds.

Technical view

Finds vectors close to a query under a distance such as cosine or Euclidean without exhaustive comparison. Main families are graph-based indexes such as Hierarchical Navigable Small World (‘HNSW’), Inverted File (‘IVF’) indexes that cluster vectors, product quantisation to compress vectors, and locality-sensitive hashing. Libraries such as FAISS implement several. Parameters trade recall against latency and memory, and recall should be measured against exact search rather than assumed. Failure modes include degraded recall after filtering by metadata, costly updates and deletions in graph indexes, and memory pressure at billion scale. It is the engine inside most vector databases.


Part of AI Terminology Index, section: Retrieval and Knowledge.

How it connects

Approximate Nearest Neighbour Search links to 8 other terms. The faint lines are links between those terms. See it in the full graph.

Vector DatabaseVector DatabaseSemantic SearchSemantic SearchEmbeddingsEmbeddingsDot Product and Cosine SimilarityDot Product and Cos…K-Nearest NeighboursK-Nearest NeighboursMetadata FilteringMetadata FilteringInverted IndexInverted IndexRetrieval MetricsRetrieval MetricsApproximate Nearest Neighbour Search