How do you choose a vector index (for example HNSW vs IVF vs flat) and does it matter?
Quick-fire answer from the Awesome Generative AI Guide (MIT)
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
A flat (exact) index compares the query against every vector, giving perfect recall but scaling poorly, so it is fine for small corpora or evaluation baselines. Approximate indexes trade a little recall for large speedups: HNSW (a navigable small-world graph) gives excellent query latency and recall at higher memory cost, while IVF (inverted-file clustering) is more memory-efficient and tunable but needs training and parameter care. The choice matters at scale for latency, memory, and cost, and each has knobs (ef, nlist, nprobe) that trade recall against speed. Start with the managed default your vector store recommends, then tune only if retrieval recall or latency becomes the bottleneck on your eval.
Full worked answer
A flat (exact) index compares the query against every vector, giving perfect recall but scaling poorly, so it is fine for small corpora or evaluation baselines. Approximate indexes trade a little recall for large speedups: HNSW (a navigable small-world graph) gives excellent query latency and recall at higher memory cost, while IVF (inverted-file clustering) is more memory-efficient and tunable but needs training and parameter care. The choice matters at scale for latency, memory, and cost, and each has knobs (ef, nlist, nprobe) that trade recall against speed. Start with the managed default your vector store recommends, then tune only if retrieval recall or latency becomes the bottleneck on your eval.
Learn more: Production topic
What a good answer covers
- A flat (exact) index compares the query against every vector, giving perfect recall but scaling poorly,…
- Approximate indexes trade a little recall for large speedups
- The choice matters at scale for latency, memory, and cost, and each has knobs (ef, nlist, nprobe) that…
- Start with the managed default your vector store recommends, then tune only if retrieval recall or…
Key terms: Learn more
Quick-fire answer from the Awesome Generative AI Guide (MIT) · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep