Apex › Storage & databases

How vector search finds nearest embeddings (HNSW)

How a vector database finds the nearest embeddings to a query — the retrieval behind semantic search and RAG — without comparing against millions of vectors. Build a proximity graph linking each vector to its nearest neighbors, then navigate it: hop toward the query, keeping the best ef candidates (a beam search). HNSW stacks layers — sparse top for long jumps, dense below — for near O(log n). Real best-first search verified: recall rises 91%→99.8% as ef grows, visiting under 20% of the vectors. Move the query and watch it navigate.

More in Storage & databases