Partition first, then search a few partitions
The corpus is clustered once, and every vector is assigned to its nearest centroid. Those clusters are the inverted lists.
A query is compared against the centroids first, which is cheap, and then only against the vectors inside the closest few clusters.
That fraction is the share of the corpus actually examined. With 4,096 lists and 16 probed, a query touches 0.4 percent of the vectors.
The two parameters
The usual rule sets the number of clusters near the square root of the corpus size, which balances the cost of scanning centroids against the cost of scanning lists.
Both terms are in that expression. Too few clusters and each list is enormous. Too many and finding the right ones becomes its own scan.
The probe count is the query-time dial: 1 is fast and misses a lot, 64 approaches a brute-force scan, and the recall curve between them is steep at first and then flat.
The boundary problem
A query near the edge of a cluster has its true nearest neighbour in the adjacent cluster, which is not probed unless is large enough to include it.
That is the structural weakness of partitioning, and it is why recall at is usually poor even though the partition is good.
Probing several neighbouring clusters fixes it statistically rather than exactly, which is the honest description of what any IVF index guarantees.
One index, in order
- Sample a few hundred thousand vectors and run k-means to get the centroids.
- Assign every vector in the corpus to its nearest centroid, building the lists.
- Store each list contiguously, so scanning it is a sequential read.
- At query time, score the centroids and pick the nearest .
- Scan those lists exactly and keep the global top .
Training on a sample is standard and safe, since the centroids only have to describe the shape of the distribution rather than every point.
Why it scales where a graph does not
Only the centroids and the current lists need to be resident, so a billion-vector index runs on a machine that could not hold a tenth of it as a graph.
Combined with product quantisation, each vector inside a list is stored compressed, which cuts memory by an order of magnitude and makes the scan faster still.
Insertion is cheap because a new vector joins one list, and deletion simply removes it, which is a real operational advantage over a graph index.
The cost is recall per millisecond. HNSW is faster at the same recall for anything that fits in memory, and IVF wins the moment it does not.