Definition
Hierarchical Navigable Small World (HNSW) is the most widely used graph-based index for approximate nearest neighbor search, and the default similarity index in many vector stores. It combines two ideas: navigable small-world graphs, where any two nodes are reachable in few hops, and the skip list, which stacks multiple layers so search can take long jumps before homing in.
How the layered graph works
HNSW builds several layers of graph over the same set of vectors. The top layer holds only a few nodes connected by long-range edges for coarse, fast navigation; each lower layer adds more nodes with shorter edges; the bottom layer contains every vector with the shortest, most local connections. A search starts at the sparse top layer, greedily walks toward the query's nearest node, then drops a layer and repeats, refining the candidate set until it reaches the dense bottom layer and returns the closest matches.
Trade-offs and tuning
HNSW delivers excellent recall and very low query latency, which is why it dominates production semantic search. The costs are higher memory use (it stores the graph edges alongside the vectors) and slower index construction. Build-time parameters like the number of edges per node and the search-time candidate list size let you trade memory and build time against recall.
For a sovereign operator, HNSW is what makes a large private corpus of embeddings searchable in milliseconds on your own box, so a local LLM can retrieve context for RAG without ever calling out to a hosted service.
Find local vector stores in the self-hosting catalog.
In Simple Terms
Hierarchical Navigable Small World (HNSW) is the most widely used graph-based index for approximate nearest neighbor search, and the default similarity index in many vector…
