Fill in the IVF nlist rule of thumb.
nlist ~ sqrt(N). Larger makes centroid comparison dominate per query work; smaller forces each partition to be large and slow to scan.
Imagine sorting a million books into boxes. Too few boxes means each box is huge and you waste time digging through one. Too many boxes means you spend forever picking which box to look in. The sweet spot is when the number of boxes is about the same as the number of books per box, which math says is roughly sqrt(N).
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
IVF is the workhorse ANN family for billion-scale vector indexes. Its two parameters - nlist (build-time) and nprobe (query-time) - control different things, and confusing them is a classic source of bad indexes. The nlist rule of thumb is the right starting point for nearly any IVF deployment, and the derivation is short enough to internalize.
What nlist actually does
IVF partitions the corpus with k-means: nlist cluster centers (centroids), each vector assigned to its nearest centroid. At query time, the search compares the query to all nlist centroids, picks the nprobe closest, and does a linear scan inside those nprobe partitions to find the actual top-K. nlist is the number of partitions - a structural, build-time choice that you cannot change without rerunning k-means and reinserting every vector.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- FAISS wiki - Guidelines to choose an index lists nlist = sqrt(N) to 16*sqrt(N) depending on recall target and corpus size.
- Milvus IVF index docs recommend nlist starting at 4*sqrt(N) for production, often refined upward.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does the per query work split evenly when nlist = sqrt(N)?
Per-query cost is nlist + nprobe * N/nlist. Minimizing for fixed nprobe via calculus gives nlist_opt = sqrt(nprobe * N). For small nprobe this simplifies to sqrt(N), where both terms equal sqrt(N) and total work is 2*sqrt(N).
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Setting nlist proportional to N (linear growth) or treating it as a recall knob; the recall knob is nprobe, and nlist is a structural balance.
60 second bullets to scan on the way to the call.
State the rule: nlist ~ sqrt(N).
Derive the rule from the per query cost equation by balancing centroid-scan and partition-scan terms.
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.