# Hierarchical Navigable Small World (HNSW)

> A fast vector index made of layers of linked points.

**Field:** Artificial Intelligence  
**Category:** Retrieval & Search  
**Also known as:** HNSW, HNSW Index

## Think of it like

Think of it like a trip. First a plane, then a train, then a walk to the door.

## Definition

Hierarchical navigable small world, or HNSW, is the most used kind of vector index. It links each vector to a few close neighbors, in layers. The top layer has a few vectors with long links, and each lower layer has more. A search starts at the top, hops toward the query, then drops down a layer at a time. It is fast and accurate, but the whole graph has to fit in memory.

## Example

Lucy's vector database uses HNSW. A search across 2 million vectors makes a few hundred hops and returns in under 10 milliseconds.

## Why it matters

Many vector databases use it by default. So its settings often decide how fast it is, how much memory it needs and how well it finds.

## Common mistake

Ignoring its memory use. The graph has to fit in RAM, and it can be larger than the vectors themselves.

## Three principles

- **Layers of links.** Few at the top, all at the bottom.
- **Hop, then drop.** Top layer down.
- **Lives in memory.** Plan for the RAM.

## Related terms

- [Vector Index](https://learn.benibix.com/term/ai/vector-index)
- [Approximate Nearest Neighbor (ANN)](https://learn.benibix.com/term/ai/approximate-nearest-neighbor)
- [Random Access Memory (RAM)](https://learn.benibix.com/term/infrastructure/random-access-memory)
- [pgvector](https://learn.benibix.com/term/ai/pgvector)

![Three stacked layers of linked points. The top layer has few points and long links, the bottom has all of them. A search path starts at the top and drops down a layer at a time.](https://learn.benibix.com/diagrams/rt-hnsw.svg)

---

Source: https://learn.benibix.com/term/ai/hierarchical-navigable-small-world
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
