Back

FLAT vs IVF

Same data, same query — but a different search strategy. Drag the query point, adjust nprobe, and press Run Search to see how IVF skips most of the data.

nprobe2
Search 2 of 8 clusters
Speed20ms
Lower = faster animation

FLAT — Brute Force

scans every point
Comparisons
200 / 200
Status
✓ Done
Recall
100%

IVF — Inverted File

searches nprobe clusters
Comparisons
33 / 33
Status
✓ Done
Recall@5
100%

What's happening?

  1. Build phase (already done): K-means partitioned the 200 points into 8 clusters. Each cluster has a centroid (the × marks).
  2. Step 1 — evaluate centroids: IVF first computes the distance from the query to every centroid. That's only 8 comparisons, regardless of dataset size.
  3. Step 2 — pick the closest nprobe clusters: these light up. All other clusters are skipped entirely.
  4. Step 3 — scan points inside the chosen clusters: only ~50 of the 200 points.

The tradeoff: larger nprobe → more clusters scanned → higher recall but slower. Smaller nprobe → faster but you may miss true neighbors that live in unscanned clusters. Try setting nprobe = 1 and dragging the query near a cluster boundary to see recall drop.