HNSW: How Vector Databases Search at Scale (2D)
A real 2D Hierarchical Navigable Small World (HNSW) graph, built from scratch: click to drop a query point and watch the greedy multi-layer search descend from a sparse top layer to the dense bottom layer, with a live distance-computation count against brute-force linear scan.
Every production RAG pipeline leans on an approximate nearest-neighbor index so retrieval stays fast as the knowledge base grows into the millions of chunks. This 2D build implements a real Hierarchical Navigable Small World graph — the same algorithm inside FAISS, Pinecone and Weaviate, and the same construction and search code as this simulator's 3D counterpart — over a synthetic 2D embedding space, laid out as separate horizontal layers so the sparse top layer and dense bottom layer are directly visible. Click anywhere to drop a query point and watch the greedy search descend layer by layer, then compare its actual measured distance-computation count against a real brute-force linear scan of every point, live, for every query you run.
Watch a Hierarchical Navigable Small World graph — the approximate-nearest-neighbor index behind real vector databases in RAG pipelines — greedily descend through sparse upper layers into a dense bottom layer to find a query's nearest neighbors, then compare recall against brute-force search.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install