Start studying
Module 8 · Embeddings & Search Module contents
Module 8  ·  Card 17 / 17intermediate

Recall vs Latency

Approximate search is a dial, not a fixed thing: every index trades accuracy against speed.

Recall here means the share of the true nearest neighbours the index actually returned.

Pushing recall from ninety to ninety-nine per cent often costs several times the query time.

The right point depends on the application, since a reranker can repair a slightly imperfect list.

Measure it against a brute-force ground truth on a sample, because untested settings are guesses.

Learn in depth ↓
Module 08 · Embeddings & Search · 17 concepts
In depth  /  15 lines

Recall vs Latency, in more detail

Exact nearest-neighbour search is easy and slow: compare the query with everything and sort.

Every practical index is approximate, and approximate means some true neighbours will be missed.

Recall at k is the measure: of the k genuine nearest neighbours, how many did the index return.

Ninety-five per cent recall at ten means that on average half a real result was lost per query.

Whether that matters depends entirely on what happens next.

Every index exposes parameters that move along this curve rather than escaping it.

In HNSW the search breadth controls how many candidates are kept while walking the graph.

In IVF it is the number of clusters probed, and in quantized indexes it is the candidate list size.

The curve is steep at the top: the last few points of recall are disproportionately expensive.

Going from ninety to ninety-nine per cent can multiply query time several times over.

The mistake is to pick a target in the abstract instead of from the application.

In a RAG pipeline a reranker reads far more candidates than the model will see, so moderate recall is fine.

In deduplication or entity matching a missed neighbour is a wrong answer, so high recall is worth paying for.

The only honest way to choose is to build a ground truth by brute force over a sample of queries.

Then plot recall against latency for a few parameter settings and pick a point deliberately.

Deep dive

What is underneath Recall vs Latency

The one curve every index is described by

recall@k=∣returned∩true top k∣k\text{recall@}k = \frac{|\text{returned} \cap \text{true top } k|}{k}

Recall is measured against what a brute-force scan would have returned, so it needs a ground truth computed exactly, once, on a sample of queries.

Report queries per second at recall 0.9, 0.95 and 0.99.

Every approximate index has a dial, and turning it trades one for the other. The only honest way to compare two indexes is at equal recall.

A benchmark reporting queries per second without a recall number is reporting nothing, since any index can be made arbitrarily fast by returning worse answers.

The shape of the curve

latency∝11−recall roughly, near the top\text{latency} \propto \frac{1}{1 - \text{recall}} \text{ roughly, near the top}

Going from 0.80 to 0.90 is cheap. From 0.95 to 0.99 often costs three or four times the work, because the last few results are the boundary cases the structure was designed to skip.

ef,  nprobe\mathrm{ef}, \; n_{\mathrm{probe}}

Those are the dials, one per family, and they are query-time parameters rather than build-time ones, so the trade can be set per request.

A search that allows a longer tail for some queries and not others is therefore possible, and it is how a system serves an interactive path and a batch path from one index.

What recall is actually worth

recallretrieval≥recallsystem\text{recall}_{\mathrm{retrieval}} \geq \text{recall}_{\mathrm{system}}

A document missed by the index cannot be recovered by anything downstream, so retrieval recall is a ceiling on the whole pipeline.

Reranking fixes order, not absence.

That is why the usual configuration retrieves many candidates at moderate recall and spends the saved time on reranking, rather than retrieving few candidates at very high recall.

k=100 at recall 0.9  >  k=10 at recall 0.99k = 100 \text{ at recall } 0.9 \; > \; k = 10 \text{ at recall } 0.99

Ninety of the true top hundred is a better input to a reranker than ten near-perfect ones, for the same latency budget.

One measurement, in order

  1. Sample a few thousand real queries, not synthetic ones.
  2. Compute the exact top kk for each by brute force, once, and store it.
  3. Sweep the index parameter across its range.
  4. Record recall and the latency percentiles at each setting.
  5. Choose the setting from the curve and the latency budget, not from a default.
p50,  p95,  p99p50, \; p95, \; p99

Report percentiles rather than an average. Approximate search has a long tail, since some queries land in dense regions and visit far more nodes than the median.

What moves the whole curve

Better recall at the same latency is not won by tuning. It comes from a better index structure, a better embedding, or fewer vectors to search.

filter first:n→n′≪n\text{filter first} : n \to n' \ll n

Metadata filtering is the largest available win when it applies, because searching a tenth of the corpus moves the curve rather than sliding along it.

Quantisation moves it too, in a way that looks wrong at first: the vectors are less accurate, more of them fit in cache, and the net effect at fixed latency is usually higher recall.

Test yourself

One question on this card. Every option explains itself once you pick, right or wrong.

Question 1
What does recall measure for an approximate vector index?
Embeddings & Search

17 concepts in this module, then a graded test with every answer explained.

Study this module →
↑↓ move↵ openesc close