Zenaique

Fill in the IVF nlist rule of thumb.

Fill in blank·Easy·4.0 · 0·~1 min·Asked atBrowserbaseCanvaPinecone·Relevant atNVIDIA
Attempt it
For an IVF index over N vectors, a common rule of thumb is to set nlist (the number of clusters) to approximately , because going much larger makes the per query centroid comparison step dominate, and going much smaller forces each partition to scan a large slice.
TL;DR

nlist ~ sqrt(N). Larger makes centroid comparison dominate per query work; smaller forces each partition to be large and slow to scan.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

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.

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.

Why nlist ~ sqrt(N)
What goes wrong with too small or too large
Operational refinements
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

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.
Sign in to see more production examples.

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)?
A

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).

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

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.

Sign in to see all red flags and common mistakes.

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.

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
HNSW vs IVF, when…
Flashcard·Medium