# Approximate Nearest Neighbors (ANN)

- **Canonical URL:** https://getaimath.com/dictionary/approximate-nearest-neighbors-ann/
- **Topics:** [Context, Memory & Retrieval](https://getaimath.com/dictionary/category/context-memory-and-retrieval/)
- **Last updated:** 2026-11-25

## What is Approximate Nearest Neighbors (ANN)?

**In one sentence:** Approximate nearest neighbors finds results that are almost certainly the closest matches, much faster than checking every item.

Comparing a query with every vector in a billion-item collection would be too slow. ANN methods organize vectors cleverly so they only check a small portion, accepting a tiny chance of missing the perfect match.

![Context Window vs. Memory: Your Desk vs. The Filing Cabinet — Simple cartoon comparing the AI Context Window (a small desk that can only fit a few pages right now) with External Memory & Search (a big filing cabinet where a librarian grabs just the 3 pages you need).](https://getaimath.com/diagrams/context-memory-and-retrieval.png)
*Napkin Diagram (Context, Memory & Retrieval): The context window is the small desk the AI can see right now; search grabs the right pages from the filing cabinet.*

## What is an example of Approximate Nearest Neighbors (ANN)?

A vector database using ANN can search 100 million vectors in a few milliseconds.

## Why does Approximate Nearest Neighbors (ANN) matter?

ANN makes vector search fast enough for real apps.

## Related Concepts

- [Euclidean Distance](https://getaimath.com/dictionary/euclidean-distance/): Euclidean distance is the straight-line distance between two points or vectors.
- [HNSW](https://getaimath.com/dictionary/hnsw/): HNSW, or Hierarchical Navigable Small World, is a popular ANN method that organizes vectors into layered networks for fast searching.
- [Cosine Similarity](https://getaimath.com/dictionary/cosine-similarity/): Cosine similarity measures how similar two vectors are by checking the angle between them.
- [FAISS](https://getaimath.com/dictionary/faiss/): FAISS is a free library from Meta for fast similarity search and clustering of vectors.
- [Similarity Search](https://getaimath.com/dictionary/similarity-search/): Similarity search finds items that are most like a given item, using a measure of closeness.
- [Chroma](https://getaimath.com/dictionary/chroma/): Chroma is a free, open-source vector database designed to be simple to use for AI apps.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/approximate-nearest-neighbors-ann/)
