# HNSW

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

## What is HNSW?

**In one sentence:** HNSW, or Hierarchical Navigable Small World, is a popular ANN method that organizes vectors into layered networks for fast searching.

Think of it like highways and local roads. The top layer has few long-distance links to jump close to the target quickly; lower layers have more local links to zoom in precisely.

![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 HNSW?

Many vector databases use HNSW as their default index.

## Why does HNSW matter?

It offers a great balance of speed and accuracy for vector search.

## Related Concepts

- [Approximate Nearest Neighbors (ANN)](https://getaimath.com/dictionary/approximate-nearest-neighbors-ann/): Approximate nearest neighbors finds results that are almost certainly the closest matches, much faster than checking every item.
- [FAISS](https://getaimath.com/dictionary/faiss/): FAISS is a free library from Meta for fast similarity search and clustering of vectors.
- [Euclidean Distance](https://getaimath.com/dictionary/euclidean-distance/): Euclidean distance is the straight-line distance between two points or vectors.
- [Chroma](https://getaimath.com/dictionary/chroma/): Chroma is a free, open-source vector database designed to be simple to use for AI apps.
- [Cosine Similarity](https://getaimath.com/dictionary/cosine-similarity/): Cosine similarity measures how similar two vectors are by checking the angle between them.
- [Metadata Filtering](https://getaimath.com/dictionary/metadata-filtering/): Metadata filtering narrows search results using extra information, such as date, author or category, alongside similarity.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/hnsw/)
