Spot the error in this candidate's description of IVF's two main parameters.
Click any words you think contain an error. Click again to unmark.
The candidate swapped the roles. nlist is BUILD-TIME (number of k-means clusters); nprobe is QUERY-TIME (how many clusters each query scans, the recall knob).
IVF splits all your vectors into buckets. nlist is how many buckets you make (decided once when you build the index, like deciding how many filing cabinets to buy). nprobe is how many buckets each query looks inside (decided per query, like deciding whether to check 1 cabinet or 10 when you are looking for something). The candidate mixed them up.
Detailed answer & concept explanation~2 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Walk the IVF lifecycle: nlist drives k-means at build, fixes the partition structure; nprobe is the runtime knob that picks how many partitions to scan, trading recall for latency. Discuss why the confusion is so common and what tuning workflow uses each correctly.
import faiss
import numpy as np
d = 768
n_vectors = 1_000_000
nlist = int(n_vectors ** 0.5) # ~1000 clusters, BUILD-TIME
quantizer = faiss.IndexFlatL2(d)
index = faiss.IndexIVFFlat(quantizer, d, nlist)
data = np.random.randn(n_vectors, d).astype('float32')
index.train(data) # k-means: this is what nlist controls
index.add(data)
query = np.random.randn(1, d).astype('float32')
# QUERY-TIME knob - changeable per request, no rebuild needed
index.nprobe = 1
D, I = index.search(query, k=10) # fast, lower recall
index.nprobe = 32
D, I = index.search(query, k=10) # slower, higher recallReal products, models, and research that use this idea.
- FAISS IndexIVFFlat exposes nlist as a constructor argument (build-time) and index.nprobe as a runtime attribute (query-time); the API split mirrors the lifecycle split.
- Milvus IVF index documentation explicitly warns against confusing nlist (set at index creation) with nprobe (set in search request).
- Pinecone's p2 pods use IVF-PQ internally with nlist fixed per pod and nprobe exposed via the top_k and search-quality knobs.
- OpenSearch's IVF implementation requires nlist at index time and exposes nprobe via the search query body.
What an interviewer would ask next. Try answering before peeking at the approach.
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Swapping nlist and nprobe. nlist is the structural build-time choice (cluster count); nprobe is the per query recall knob (how many clusters to scan).
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.