The interview problem

Practice prompt

An enterprise search assistant handles 100 queries per second. Its initial retrieval returns 20 authorized passages. A slower retrieval and reranking pass can sometimes recover missing evidence. Design a predictor that estimates initial retrieval failure before answering, and a policy that decides whether to use the initial results, invoke fallback, clarify the question or abstain.

Original ML-design practice, not a reported company interview. Workload, utilities and examples are hypothetical. Primary query-performance research abstracts consulted September 27, 2026.

1. Define retrieval failure separately from answer failure

Define failure as the initial result set lacking sufficient authorized, applicable evidence to address the question under a human evaluation rubric. Fix the corpus version, user context and retrieval configuration associated with each example. A multi-part question may fail even when its first passage is highly relevant, because another required fact is missing.

This target is not equivalent to zero results, a low similarity score, slow search or an incorrect generated answer. The generator can misuse adequate evidence, and a confident retriever can return an irrelevant cluster. Post-generation answer verification remains a separate component.

Distinguish retrieval misses, ambiguous intent, stale versions, missing corpus content and access restrictions. A second search pass may help the first case while doing nothing useful for the others. Missing permission never authorizes the fallback to widen access.

2. Predict quality, then choose an action

question + user context → initial authorized retrieval
                                      ↓
                         query and result features
                                      ↓
                        calibrated failure estimate
                                      ↓
                       budgeted action policy
                      /        |         |       \
                 initial   fallback   clarify   abstain
                      \        /
                       generation → answer verification

Log the index and retriever versions, available features, predicted risk, selected action and eventual evaluated outcomes. A model score and a policy decision are different artifacts: the best action depends on costs, repairability and capacity, not just the chance of failure.

Keep the initial evidence snapshot for evaluation even when fallback replaces it. Otherwise labels can accidentally describe the final results while features describe the initial ones. Preserve authorization context and source versions without unnecessarily copying sensitive text into logs.

3. Use features available at decision time

Feature familyPotential valueFailure mode
Query entities, length and specificityIdentify missing context or unusual requestsLong queries can still be easy; short ones can be precise
Score gaps and score distributionDescribe ambiguity among retrieved candidatesScores are not universal probabilities across rankers
Lexical/dense result agreementExpose retrieval disagreementBoth systems may share the same blind spot
Duplicate fraction and source diversityReveal repeated evidence or missing perspectivesDiversity alone does not establish relevance
Version match and required-entity coverageCheck applicability to the questionMatching words can occur in irrelevant passages

Start with a simple baseline such as a calibrated classifier over inexpensive query and result features. Compare against score-only and always-fallback baselines. Pre-retrieval predictors save work but cannot inspect the actual result set; here the initial results already exist, so post-retrieval features are available.

Future clicks and reformulations are unavailable for the first decision on this request. Historical aggregates can be features only with a valid time boundary. Do not define the gold failure label using the same heuristic supplied as a feature: that trains a heuristic imitator rather than a predictor of independently judged quality.

4. Derive a fallback threshold that includes harm

Let p be the calibrated probability that initial retrieval fails. Assign an initial failure a loss of 10 utility units. Suppose fallback costs 0.4 units, repairs 60% of initial failures, and spoils 2% of initially successful retrievals. These rates are hypothetical conditional estimates for the evaluated population. In this calculation, fallback replaces the initial evidence set, success has zero loss, and any remaining retrieval failure has the same loss of 10. The fallback cost uses the same utility scale; it is not added directly to a latency measured in milliseconds.

initial expected loss = 10p
fallback expected loss = 0.4 + 10[0.4p + 0.02(1−p)]
                       = 0.6 + 3.8p
fallback improves expected utility when:
10p > 0.6 + 3.8p
p > 0.6/6.2 = 3/31 ≈ 9.68%
Initial failure riskInitial lossFallback lossPreferred under these assumptions
20%2.001.36Fallback; gain 0.64
5%0.500.79Initial results; fallback worsens loss by 0.29

A failure predictor alone does not establish fallback benefit. If an index lacks the required document, another pass may have nearly zero repair probability. For a narrowly phrased query, expansion might raise the harm probability. Estimate conditional repair and harm by relevant slices, or directly estimate incremental action value. Do not apply one population-wide threshold as though all queries had identical treatment effects.

Clarification and abstention require their own utility models: user delay, probability of obtaining useful context and cost of leaving the question unresolved. Do not force them into the same binary fallback threshold. Use explicit missing-version or ambiguous-entity signals where possible rather than asking generic clarification questions for every high-risk query.

5. Build labels that distinguish failure causes

Have reviewers judge whether the initial authorized passages cover the required facts and applicable versions. Retain adequate, insufficient and uncertain labels with reasons. A deeper authorized search can help distinguish a retriever miss from apparent corpus absence, but incomplete judging pools still leave uncertainty; failure to find a document is not definitive proof that none exists.

Split by query family, customer and time as appropriate. Group duplicates and paraphrases so near-identical requests do not leak across train and test. Preserve the permissions-filtered corpus context: a passage relevant to one user may be unavailable to another.

Use separate calibration, policy-selection and untouched evaluation data. Assess probability quality with calibration plots and proper scoring metrics, then evaluate failure capture at the available fallback budget. Ranking correlation or AUCPR alone does not establish good probabilities or a useful action policy.

6. Measure alternatives despite selective feedback

If fallback runs only for high-risk queries, its observed outcomes do not reveal how it would perform on low-risk queries. Nor does a high post-fallback success rate prove improvement: many selected requests may already have adequate initial evidence.

On an approved sample, run both retrieval strategies in shadow and adjudicate their evidence sets against the same rubric. Record initial-success-to-failure transitions as well as repairs. Shadow evaluation measures evidence quality without changing the user's response, but it still incurs compute and must respect data-access boundaries.

Use an appropriate online experiment to assess end-to-end effects such as latency, user behavior and answer usefulness. Off-policy evaluation requires known action probabilities and sufficient support; a deterministic policy provides no observations for actions it never takes in a context. Audit low-risk accepted requests as well as flagged ones to detect silent misses.

7. Budget extra work and latency

At 100 queries per second and a 20% fallback rate, the fallback service receives 20 requests per second. If its additional mean residence time is 350 milliseconds in stable operation, Little's law gives an average of 20 × 0.35 = seven fallback requests in flight. That is not a worker count or a tail-capacity guarantee.

feature and predictor time on every request = 15 ms
extra fallback time on 20% of requests = 350 ms
mean added latency = 15 + 0.20 × 350 = 85 ms
added latency on a fallback request = 365 ms

The example assumes sequential stages and the stated mean costs. It does not determine p95 latency. Correlated bursts, queues and slow dependencies can dominate the tail. Load-test the action policy together with fallback service capacity.

When only 20 fallback requests per second are affordable, prioritize positive estimated incremental benefit under the actual cost constraint. Ranking by failure risk is justified only under suitable assumptions about equal costs and treatment effects. Apply tenant fairness and deadlines, and cap retries so an overloaded fallback does not recursively trigger more fallback work.

8. Recalibrate when retrieval changes

Begin with shadow predictions, then a constrained pilot with rollback to the previous policy. Track initial evidence adequacy, post-action adequacy, harmful replacements, clarification and abstention rates, answer quality, latency and cost. Break results down by query type, customer, language, permissions filtering and index version.

A new embedding model, ranker or corpus can change score distributions and repairability. Version features and refresh calibration before assuming the old threshold remains meaningful. Missing features or predictor outages need a bounded default policy; always invoking an expensive fallback can turn a small failure into a service overload.

9. Failure analysis and self-review

  • Coherent but irrelevant results: agreement and topic concentration can be confidently wrong; judge required facts and entities.
  • Old-version cluster: every result supports obsolete instructions; include applicability evidence.
  • Unavailable source: fallback cannot bypass access restrictions or repair absent corpus coverage.
  • Label leakage: future interaction or final evidence enters initial-risk training; preserve decision-time snapshots.
  • Selective feedback: only flagged queries are audited; sample accepted queries and evaluate alternatives.
  • Unhelpful fallback: a high failure score triggers an action with low repair benefit; model action value separately.
  • Budget cascade: overload increases latency and retries; bound work and define degradation behavior.

Follow-ups: How does a multi-turn conversation change the target? What if the query is answerable only after clarification? How would you evaluate corpus absence? When should initial and fallback results be combined rather than replaced? How do permissions changes affect labels? What does a ranker upgrade invalidate?

  • Define initial retrieval adequacy independently from generated-answer correctness.
  • Use runtime-available features and independent labels.
  • Separate failure risk from fallback repair and harm.
  • Derive a decision rule with explicit utility assumptions.
  • Evaluate selective feedback and unchosen alternatives.
  • Budget mean load without claiming tail guarantees.
  • Monitor policy outcomes and recalibrate across retrieval versions.

Sources and attribution

Retrieved September 27, 2026. No interview date applies. The architecture, policy example and calculations are original; cited research does not establish performance of this proposed system.

Continue your preparation

Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.