advanced24 min studyLesson 659 in Engineering

Measure a frontier instead of selecting one flattering number

Define exact recall with ties, held-out queries, bounded uncertainty, and comparable latency-memory operating points.

On this page

What you’ll understand

  • Calculate mean recall over independent query units.
  • Identify leakage, tie, timeout, and denominator mistakes.
  • Compare nondominated points with all cost boundaries stated.

A retrieval setting is useful only relative to a workload and a resource budget. One index can achieve higher recall by scanning more candidates, another can reduce latency by spending more memory, and a third can look fast because timed-out queries vanished from its report. A meaningful experiment records the complete operating point: recall definition, latency distribution, memory boundary, concurrency, and snapshot identity. The goal is a reproducible frontier of feasible tradeoffs, not a single setting selected after repeatedly inspecting the same small test set.

Define what counts as a recovered neighbor

For each query, build a deterministic exact top-k reference using the same metric, normalization, eligible population, and document versions as the approximate search. Count unique logical IDs after deduplication. A returned document with a stale version is not automatically the current reference item. If equal scores straddle the cutoff, either fix a shared total tie order or report a carefully defined tie-aware alternative alongside the strict measure. Do not switch definitions only for difficult examples.

Recall@k measures overlap with geometric neighbors, not human relevance or successful downstream answers. Evaluate those separately. Also keep one-nearest-neighbor-found-in-top-R distinct from intersection recall at R: they answer different questions even when both are called recall informally. Include empty populations, short lists, and timeouts under a declared policy. Removing failures from the denominator can improve the reported average while the application actually receives fewer useful responses.

Rˉ=1n∑i=1n∣Ak(qi)∩Gk(qi)∣k\bar R=\frac1n\sum_{i=1}^{n}\frac{|A_k(q_i)\cap G_k(q_i)|}{k}
Assume n positive-count queries, at least k eligible IDs for each, and at most k unique returned IDs; missing slots count as misses. All scores are dimensionless. Queries with smaller eligible populations require a separately specified denominator policy.↔ Scroll wide equations horizontally.

Hold out the final comparison

Use training data to learn coarse and PQ codebooks, a validation workload to select search parameters, and a held-out test workload to estimate the chosen configuration’s behavior. Corpus training and query evaluation play different roles, so record their sampling and any overlap deliberately. Parameter selection on the final test queries leaks information into the reported estimate even if no encoder weights changed. After extensive tuning, gather another independent query set or disclose the selection procedure.

Uncertainty should respect the sampling unit. Treating k neighbors from one query as k independent Bernoulli trials usually exaggerates the amount of evidence because those successes share a query and traversal. Independent query-level recalls lie in [0,1], allowing a conservative bounded-variable concentration bound for their mean. Real correlated sessions weaken that assumption; block or session-level analysis may be more appropriate. No interval fixes a biased workload that excludes the users or filters that fail.

Pr⁡ ⁣(∣Rˉ−ERˉ∣≥ε)≤2e−2nε2,ε=ln⁡(2/δ)2n\Pr\!\left(|\bar R-\mathbb E\bar R|\ge\varepsilon\right)\le2e^{-2n\varepsilon^2},\qquad\varepsilon=\sqrt{\frac{\ln(2/\delta)}{2n}}
Hoeffding’s two-sided bound assumes independent query-level recalls in [0,1] and a configuration fixed before these queries are evaluated. n is a count, 0<δ<1, and ε is dimensionless. It is conservative and does not correct adaptive test-set selection or distribution shift.↔ Scroll wide equations horizontally.

Compare whole operating points

A point is dominated if another measured configuration has at least its recall with no greater latency or memory, with at least one strict improvement, under the same workload and measurement boundaries. Specify which latency statistic is used; mean latency and p99 are not interchangeable objectives. Count resident vectors, codes, graph links, IDs, temporary buffers, and required reranking storage consistently. Build time and ingestion cost can be additional dimensions rather than costs quietly excluded from the decision.

Run load experiments at controlled concurrency and arrival patterns, record warm-up and cache conditions, and retain timeout counts. A query that is fast in isolation may queue badly under saturation. Repeat measurements enough to distinguish noise from a practical improvement, while avoiding a search for the luckiest run. Store the exact query list, configuration, machine description, and artifact hashes so an apparent regression can be traced to a changed workload, changed index, or changed measurement setup.

Mean recall and a conservative query-level bound

At k=2, four held-out queries recover 2, 1, 2, and 1 exact neighbors after deduplication. Separately, consider n=100 independent test queries for a configuration fixed beforehand and confidence parameter δ=0.05. Compute the small example mean and the large-sample Hoeffding radius.

  1. Convert recovered counts to per-query recalls: 1, 0.5, 1, and 0.5. Their sum is 3, so mean recall is 3/4=0.75. The sampling units are four queries, not eight independently recovered-neighbor trials.

  2. For the separate n=100 experiment, ln(2/δ)=ln40≈3.688879. Divide by 2n=200 to obtain approximately 0.0184444, then take the square root to get ε≈0.13581.

  3. If that 100-query experiment happened to observe mean 0.75, the conservative two-sided interval from this bound would be approximately [0.61419,0.88581], clipped to [0,1] if necessary. The four-query calculation alone does not justify using n=100.

The result

The example mean is 0.75. Confidence depends on the actual independent query count and selection protocol; a convenient number of neighbor slots cannot replace those assumptions.

Explore the model

Interactive lab

Interactive lab · sampling

More independent queries narrow a toy sampling distribution

Reset, set Success probability p to 0.5 and Independent samples n to 20. Predict sample-mean variance 0.0125 before Step. Reset, set p to 0.5 and n to 100, predict variance 0.0025 before Step. Playback highlights exact binomial outcomes rather than drawing random queries. This Bernoulli special case illustrates sampling uncertainty, not real ANN recall or a query-bootstrap implementation.

More independent queries narrow a toy sampling distributionExact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Current readings: Mean sample proportion: 0.5; Sample-mean variance: 0.0125; Uniform CDF error bound: ≤ 0.1062. All parameters are adjustable with the labeled controls below.Exact distribution of the mean of 20 independent Bernoulli variables with success probability 0.5; playback highlights outcome 0.00.250.50.75100.0580.1150.1730.23Sample mean · k / nProbability massNormal bin masses are an approximationk = 0 · exact probability = 9.54e-7
Exact binomial massNormal interval massHighlighted outcome / mean
Mean sample proportion
0.5
Sample-mean variance
0.0125
Uniform CDF error bound
≤ 0.1062
t = 0 s

Exact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forIncreasing independent sample count narrows uncertainty under the model; representativeness and independence remain assumptions.

Check your understanding

Which procedure best supports an honest final recall estimate after parameter tuning?

Try it yourself

Under identical workload and measurement rules, point A has recall 0.90, p95 latency 5 ms, and memory 2 GB. Point B has recall 0.92, p95 4 ms, and memory 2 GB. Point C has recall 0.95, p95 6 ms, and memory 3 GB. Which points are dominated among these three?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Compare every named objective; higher recall is better while lower latency and memory are better.

Compare with the solution

A is dominated by B because B has higher recall, lower p95 latency, and equal memory. B and C are both nondominated within this three-point set: C improves recall but uses more memory and has higher p95 latency. This finite comparison does not establish the complete achievable frontier or compare unmeasured build costs.

Take it with you

  • Define exact references, ties, failures, and unique-ID denominators.
  • Use held-out query units and state uncertainty assumptions.
  • Compare nondominated recall, latency, and memory points under one measurement boundary.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.