HNSW (Hierarchical Navigable Small World)
The most popular algorithm for approximate nearest neighbor search in vector databases, providing fast and accurate similarity search for embedding-based applications.
How It Works
HNSW builds a multi-layer graph where higher layers contain fewer, more distant connections (for quick coarse navigation) and lower layers contain many local connections (for precise final search). Search starts at the top and navigates down.
Performance
HNSW offers excellent recall (>95%) at high throughput (millisecond queries). It's the default index type in most vector databases (Pinecone, Weaviate, Qdrant, pgvector). The tradeoff is higher memory usage compared to quantization-based methods.