Vector Indexes: HNSW, IVF and Friends
Finding the nearest neighbors of a query vector among N vectors by brute force costs O(N·d) per query. At 10M vectors × 768 dims that's ~7.7 billion multiply-adds per query, too slow for interactive use. Approximate Nearest Neighbor (ANN) indexes trade a little recall for orders-of-magnitude speed.
In this lesson
- The core trade-off
- HNSW: Hierarchical Navigable Small World
- IVF: Inverted File Index
- Compression: Product Quantization (PQ)
- Choosing an index
- Hands-on with FAISS
- What a vector database adds over an index
This lesson is part of AI Engineering. Unlock the full course to read it, take the quiz and track your progress.