ML//RAG//HNSW

- Hierarchical Navigable Small World: the dominant algorithm for approximate nearest neighbor (ANN) search.


Hierarchical Navigable Small World: the dominant algorithm for approximate nearest neighbor (ANN) search.

Multi-layer graph: upper layers have long-range connections (fast coarse search), lower layers short-range (precise local)

The algorithm inside most vector databases: Pinecone, Weaviate, Qdrant, pgvector all use HNSW or variants.

Tradeoff: orders of magnitude faster than exact search, but approximate — 95-99% recall is typical.