Dev.to
7/9/2026

The original title is "How Vector Search Actually Works: IVF and HNSW"
Original: How Vector Search Actually Works: IVF and HNSW
Short summary
Vector search powers semantic applications like RAG and recommendation engines by finding approximately nearest neighbors among millions of high-dimensional embeddings. Two algorithms dominate: IVF clusters vectors via k-means and searches only the most relevant clusters, while HNSW builds a layered graph for fast navigation with higher memory cost. Both trade exactness for speed through a recall-versus-latency dial, with IVF offering simplicity and compression via Product Quantization, and HNSW delivering better recall at the cost of memory.
- •IVF partitions vectors into k-means clusters and probes only the nearest ones, trading nprobe for recall vs speed
- •HNSW builds a hierarchical graph navigated top-down for fast approximate search with higher memory usage
- •Product Quantization compresses vectors for billion-scale IVF indexes that fit in memory
Generated with AI, which can make mistakes.
Is this a good recommendation for you?


