Approximate Nearest Neighbor Search (ANN)

Finding the most similar vectors quickly enough for real systems, even when exact search would be too slow.

How many true neighbors did a fast search recover?

For a catalogue query, an exhaustive search returns objects A, B, C and D. A faster approximate index returns A, C, D and F using the same embeddings and distance metric.

Quality

Three of the four exact neighbors appear in the approximate list. Recall at four is 3/4, or 75%, for this query.

Cost

Measure query latency and memory on the same index size, hardware and workload. A quick result can still miss the object the reader needs.

What else to compare

Repeat across representative queries and tie cases. This comparison tests agreement with exact search; whether the distance metric matches curatorial relevance is a separate evaluation.

Why It Matters

ANN search matters because modern AI systems often store images, documents, audio clips, or other content as embeddings. Once a collection grows large, brute-force comparison becomes impractical. ANN indexes make it possible to search millions or billions of vectors quickly enough for interactive applications such as visual search, recommendation, and semantic retrieval.

How It Works

Different ANN systems use different strategies. Some cluster vectors and search only the most promising regions. Some compress vectors into more compact forms. Some build graph structures that let the search walk toward likely neighbors instead of scanning the entire dataset. In all cases, the goal is the same: preserve most of the useful nearest-neighbor behavior while reducing latency and compute cost.

What To Keep In Mind

ANN search is not magic. The quality of the result still depends on the embedding model, the index design, and the business rules layered on top. A faster index will not fix weak representations. But when the embeddings are strong, ANN search is one of the key reasons large-scale retrieval can feel immediate instead of sluggish.

Follow the idea

Related concepts (5)

Source · Faiss documentation on similarity search

Return to Approximate Nearest Neighbor Search (ANN) in the A–Z glossary