Skip to content
ReviewRamble

The weekly brief

AI, reviewed, in your inbox.

  • New reviews of tools, models, MCP servers and repos, with the verdict up front
  • Re-checked prices and ratings when something changes
  • New analysis pieces as they are published

Models, agents, MCP servers and the tools actually worth your time.

One email a week. Unsubscribe with the link in any brief. How we use your email

HNSW

HNSW (hierarchical navigable small world) is a graph-based index for approximate nearest neighbor search. It links vectors to their neighbors across several layers, so a search can hop quickly toward the closest matches.

Also called: hierarchical navigable small world, HNSW index

By Divya Sharma · Checked Nov 15, 2026 · How we review

HNSW is the default index in many vector databases. It was described by Malkov and Yashunin in a paper first posted in 2016, and it is popular because it gives high recall with fast queries and needs no training step.

How it works

Each vector becomes a node linked to some of its nearest neighbors. The graph has several layers. The bottom layer holds every vector; each higher layer holds a random, shrinking subset, so the top is sparse with long links. A search starts at the top, moves greedily toward the query, then drops a layer and repeats with finer steps until it reaches the bottom. The paper reports logarithmic scaling of search cost.

Think of it like finding an address: motorway first, then main roads, then side streets.

Settings you will see

The main knobs are how many links each node keeps (often called M), how wide the search is while building the graph (ef_construction) and how wide it is at query time (ef or ef_search). Higher values raise recall and cost more memory or time. Tune them against retrieval metrics on your own data.

Limits

HNSW keeps the graph and usually the vectors in memory, which gets expensive at large scale. Deleting items can leave the graph less well connected, and combining it with strict metadata filtering can lower recall. Other approximate nearest neighbor indexes trade these costs differently.

Related terms

Approximate nearest neighbor search
Approximate nearest neighbor (ANN) search finds vectors close to a query without checking every stored vector. It gives up a guarantee of the exact best match in exchange for much faster search on large collections.
Vector database
A vector database stores embeddings alongside their source records and finds the stored vectors closest to a query vector, usually with an approximate index so search stays fast across millions of items.
Vector search
Vector search finds items by comparing their embeddings to the embedding of a query and returning the closest ones, so results match on meaning rather than on shared keywords.
Metadata filtering
Metadata filtering limits a search to items whose stored attributes, such as date, author, language or access group, match given conditions, alongside or before ranking them by vector similarity.
Retrieval metrics (recall@k, nDCG, MRR)
Retrieval metrics score how well a search system returns relevant documents. Recall@k checks how many relevant items appear in the top k, nDCG rewards ranking them high, and MRR measures how early the first correct one appears.

Sources