esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

How Does IVF Indexing Work?

How IVF sorts stored vectors into lists, why a search opens only a few of them, and the trade-off it makes, explained simply for your AI interview.

In short

IVF sorts the stored vectors into lists, one per cluster centre. A search compares the question with the centres, then opens only the few lists nearest to it, so most of the data is never read. It is faster, but it can miss the best match when that match sits in a list nobody opened.

11 min readAdvancedOccasional · estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

IVF stands for inverted file. When I build the index, I first pick a set of cluster centres, then file every vector in the list of its nearest centre. At search time I compare the question only with the centres, open the few nearest lists, and compare inside them. That skips most of the data, so it is fast. The catch is that the best match can sit in a list I didn't open, so I tune how many lists I open against the recall I need.

What is IVF indexing, in plain words?

An AI search tool stores each item as a vector: a long list of numbers that stands for its meaning. To find the items closest to a question, it compares the question's vector with the stored ones. Doing that against ten million vectors on every search is slow.

IVF, short for inverted file, is a shortcut. It sorts the stored vectors into groups first, then searches only the few groups most likely to hold the answer. Faiss, an open-source toolkit for vector search, describes it as clustering the data at indexing time and searching only part of it.

Think of a records clerk at a law firm. Contracts sit in labelled drawers by topic. A lawyer asks about late-payment clauses, and the clerk opens the three drawers that fit instead of all 40,000 contracts. The drawers are the lists, and the labels are the centres.

Here is the same idea on a real job: a legal team searches ten million clauses by meaning. IVF lets the search open a small share of them and still find the right clause often.

Key words

Vector
A list of numbers that stands for the meaning of a clause, photo or document.
Centroid
A cluster centre. Each list is built around one centroid.
Inverted list
The group of vectors filed under one centroid, stored together.
nprobe
How many lists a search opens. More finds more matches but reads more data.
Recall
The share of true best matches a search actually finds.

How does IVF build its index?

Building has two steps. A clustering step first picks a set of cluster centres that cover the data. Each centre is a centroid. Then every stored vector joins the list of its nearest centre.

  1. 1

    Pick the centres

    A clustering step, such as k-means, learns a set of centres from the stored vectors. More centres give smaller lists.

  2. 2

    File every vector

    Each vector is filed in the list of its nearest centre. The lists are the inverted lists, and the whole store is the inverted file.

  3. 3

    Fix the list count

    The number of lists, called nlist in Faiss, is a field on the IndexIVF object.

Building an IVF index

Stored vectors

one per clause, document or photo

Cluster centres

centroids that cover the data

Inverted lists

each vector filed under its centre

  1. 1A clustering step learns the centres from the stored vectors.
  2. 2Each vector joins the list of its nearest centre.
Stored vectors teach the cluster centres, then each vector is filed under its nearest centre. The search later uses these lists.
  • “IVF indexing is a technique that clusters the database vectors at indexing time.”

    The Faiss library paper, version 4

What does IVF cost you, and when is it the right choice?

Faiss describes two ways to skip most of the data, inverted files and graph-based search. Each one trades memory and speed against accuracy.

  • Graph-based

    Needs memory to spare

    Good when memory is not the limit, typically for indexes below 1M vectors. Building it gets slow beyond 10M vectors.

  • IVF

    Lighter, but approximate

    It opens only some lists, so it can miss matches. It pairs well with compression for very large sets.

  • “For larger indexes, where compression is required to even fit the database vectors in memory, IVF indexes are the only option.”

    The Faiss library paper, version 4

  • Recall is lost at the edges

    A true match just across a boundary sits in a list the search never opened.

  • Lists can grow unequal

    Faiss measures this as an imbalance factor. Lopsided lists make some searches much slower.

  • Training data has to look like real data

    Centres learned from a different mix of documents put the lists in the wrong places.

Compressing the vectors is what makes IVF fit very large sets, and it is covered in the product quantization answer.

How would you size nlist and nprobe for ten million clauses?

I would start from the memory budget and the recall target. Then I would run real questions that have known correct answers at several nprobe values, and pick the smallest nprobe that meets the bar.

Tip

Say that the right setting depends on the data and the accuracy you need, then show the test you would run to find it.

What does the interviewer want to hear?

A strong answer covers

  • IVF in one sentence: vectors are grouped by nearest centre, and a search opens a few groups.
  • The two build steps: learn the centres, then file each vector.
  • nprobe as the speed and recall dial, set per query.
  • Where it misses: the best match sits in a list that was not opened.
  • When to pick it: very large sets, usually with compression.
  • How you tune it: measure recall on real questions with known answers.

Common traps

  • Trap"It is an exact search, just faster."

    BetterIt is approximate. It skips lists, so it can miss the best match.

  • Trap"More probes always means a slower search."

    BetterOpening more lists raises recall at a cost in speed. Measure both before you pick nprobe.

  • Trap"Set the list count once and forget it."

    BetterWatch list sizes and recall after each data refresh, since lopsided lists slow searches.

Can you spot the risk?

Spot the risk

A 10 million vector index misses true matches often. Which setting causes the most misses?

Quick check

A legal search misses the right clause in about 1 search in 5. What is the most direct setting to change?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q120How does HNSW work?11 min
  2. Q122What is product quantization?12 min
  3. Q119What is approximate nearest-neighbour search?10 min
  4. Q117What is a vector database?12 min
  5. Q123What is hybrid search (BM25 + vectors)?11 min
  6. Q118Cosine vs dot product vs Euclidean distance?11 min

Last updated on 27 November 2026

Building a search over millions of documents or photos?

I design and build AI search and agents, including the index behind them. Book a short call and tell me how many items you have and how fast answers must come back.