HNSW
Also known as: Hierarchical Navigable Small World
HNSW is a popular graph-based ANN index: multi-layer proximity graphs enable roughly logarithmic-time search with strong recall. It is widely used inside vector databases and libraries like FAISS for dense retrieval at moderate-to-large scale.
Intuition
Upper layers are sparse “highways” for long jumps; lower layers refine neighbors locally. Search enters at the top, greedily walks toward the query, then descends layers for finer candidates.
Knobs
- M — connections per node (memory vs recall)
- efConstruction / efSearch — build and query candidate list sizes (speed vs quality)
HNSW is in-memory heavy compared with compressed IVF-PQ; pick it when recall and latency matter more than minimal RAM. Always validate recall@k on your embedding space—graph quality is data-dependent.