AI Glossary Term

What does “ANN (Approximate Nearest Neighbor)” mean?

Definition

Algorithms that find vectors close to a query without exhaustive comparison, trading exactness for speed.

How ANN (Approximate Nearest Neighbor) works

Diagram for ANN (Approximate Nearest Neighbor) comparing Exact search (Compare query to every vector, Slow at scale) versus Approximate search (Use an index to skip most vectors, Very fast, tiny chance of a miss).Exact searchCompare query toevery vectorSlow at scaleApproximate searchUse an index toskip most vectorsVery fast, tinychance of a missvs

Example

Among 100 million stored vectors, an index narrows the search to a small neighborhood and checks only those. The result is nearly the same as checking all of them, in a fraction of the time.

Why it matters

Fast similarity search is the engine of semantic search and retrieval. The speed gain costs a small chance of missing the very best match.

Common questions

How accurate is it?

Typically a high share of the true nearest neighbors, with settings to trade accuracy for speed.

Which methods exist?

Graph-based such as HNSW, clustering-based, and hashing-based approaches.

When is exact search fine?

For small collections, where comparing everything is fast enough.

Learn more in our free guides

Test yourself

See also