The interview problem
A search product wants to show why a document matched a query. Design concise explanations that stay truthful when ranking uses embeddings, popularity and personalized signals.
Original practice, not a reported company interview. All worked numbers are illustrative. Interview date: not applicable. Written October 3, 2026.
1. Scope and assumptions
Separate evidence that supports relevance from a faithful account of the ranker’s complete decision. A highlighted phrase is not a causal explanation of a neural score. Do not expose private personalization features.
2. Architecture and decisions
Result ID and version → allowed evidence spans → explanation template or generator → entailment checks → display
Attach explanations to the exact document version and query. Prefer deterministic explanations when structured evidence is sufficient: matching title terms, compatible attributes or a cited passage. If generating prose, constrain it to retrieved evidence spans and require every factual claim to map to a span. Label the result as supporting evidence rather than claiming to reveal every ranking factor.
Apply the same access policy to snippets as to documents. If a document changes before display, regenerate or omit its explanation. Cache by query, document version and visibility scope. Keep a fallback that simply shows an extract; an explanation is optional and must not block the main search path.
3. Work through the example
Suppose reviewers assess 200 explanation claims and find 190 directly supported, 6 unsupported and 4 contradicted. Supported-claim precision is 190/200=95%. Combining the last two categories as merely “not ideal” hides the more serious contradictions. Separately measure what fraction of results receives an explanation.
4. Failure cases and trade-offs
A fluent explanation can be plausible yet unrelated to why the item ranked. Highlighting engines can show matches that do not exactly reflect complex Boolean logic. Long generated rationales increase latency and unsupported detail. Extractive snippets trade elegance for easier verification but still need context and version checks.
5. Validation and acceptance
Use counterfactual queries, negation, revoked documents and edited passages. Review evidence support separately from usefulness and ranking quality. Test that omitting an explanation leaves search results usable and that snippet caches cannot cross permission boundaries.
6. Follow-ups and self-review
Would an explanation improve trust even when it is unfaithful? Reward distinction between evidence and causality, version binding, safe omission and claim-level evaluation.
Sources and related practice
Elasticsearch highlighting documentation describes matching excerpts and limitations; the evidence-bound explanation design is original.
Read the primary technical reference
Reference retrieved October 3, 2026. Retrieval date is not an interview or source publication date. The reference supports the named concept; scenario, architecture, examples and rubric are original.
Continue with Search Ranking System Design: Retrieval, Ranking and Evaluation; Verify generated answers against evidence.
Continue your preparation
Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.