The interview problem

Practice prompt

Build enterprise search over ten million document chunks in English, Japanese, German and Spanish. Employees may ask in a different language from the best source. Preserve product codes, respect document permissions and return useful results within a 400 ms target. Explain how you would detect a language-specific regression hidden by an improved overall score.

Original ML-design practice, not a reported company interview. Languages, scale and budgets are hypothetical. Primary research retrieved September 27, 2026.

1. Define cross-language relevance

A relevant result answers the user's information need and is accessible to that user. Query language, document language and preferred display language are separate fields. A Spanish question may legitimately retrieve an English technical specification. Language detection is a routing hint, not an authorization rule or proof of user preference.

Preserve original source text and version. Translations are derived artifacts linked to the source, never a replacement for its identity or permission policy. Show the source language, label translated snippets and let users inspect the original passage.

Begin with document retrieval, not generated answers. Evaluate whether the needed source is retrieved before adding a generator that could conceal retrieval failures behind fluent prose.

2. Index complementary representations

Connectors capture document identity, tenant, source version, access metadata and deletion state. Parse text while preserving section boundaries, tables and identifiers. Segment by semantic structure within the encoder's token limit; equal character lengths are not equivalent token lengths across languages.

Create a lexical index using language-appropriate analysis plus an exact field for identifiers. Create dense vectors using a multilingual encoder whose query and passage formats match its training recipe. Store the encoder version with each index generation. Never query vectors produced by one incompatible model with another model's query representation.

Normalize Unicode carefully, keeping the original alongside normalized fields. Blind accent removal or transliteration can merge distinct terms. Product names, mixed scripts, code fragments and short queries deserve explicit fixtures rather than a single language label for the entire document.

3. Retrieve, fuse and rerank

The request gateway authenticates the employee and resolves the current tenant and access context. In parallel, run lexical retrieval over the original query and multilingual dense retrieval. Optionally add a translated-query branch for weak language pairs, protecting product codes and retaining the original branch as a fallback.

Combine candidate lists by a declared rank-fusion rule or calibrated scoring model; raw lexical scores and cosine similarities are not directly comparable. Deduplicate source chunks and translated copies so one document does not occupy the entire candidate budget. Rerank the union with a model validated on the relevant query/document language pairs.

Use access-aware filtering during candidate retrieval where supported, then recheck current authorization before returning snippets or sending content to a reranker outside the trusted retrieval boundary. An external translation or reranking service also needs approval to receive the query or document under the tenant data policy; user access to a document does not by itself authorize exporting it to another processor. A final filter alone may leave too few results when most top candidates are inaccessible. Overfetching can improve coverage but is not a substitute for isolation or bounded work.

The final result includes source identity, revision, language, snippet and relevance evidence. Cache keys include tenant, query representation and access context; revalidate revocations rather than trusting an old permission snapshot indefinitely.

4. Work the capacity and latency budget

Ten million chunks with 768-dimensional float32 vectors require 10,000,000 × 768 × 4 = 30.72 GB of raw vector payload. Two copies require 61.44 GB before approximate-neighbor structures, text, metadata and lexical indexes. An average 1 KB of chunk metadata adds 10 GB before replication.

Suppose lexical search contributes 100 candidates and dense search contributes 100, with 40 shared identities. The union has 160 unique candidates. Reranking all 160 at 500 queries/second requires 80,000 query–passage scores/second. If a worker sustains 2,000 such scores/second under the actual length mix, forty workers provide only the arithmetic minimum, with no spare capacity.

For an illustrative request, spend 30 ms resolving access, 90 ms on parallel retrieval, 15 ms fusing candidates, 160 ms reranking and 25 ms on final filtering and response: 320 ms, leaving 80 ms in a 400 ms budget. Summing stage budgets does not prove end-to-end p95. Measure the full distribution under load, including queueing and slow language slices.

Translation can consume the margin. Run it only under a bounded policy, use an appropriate cache and return the original-query results if that branch misses its deadline. Track degraded responses rather than mixing them silently into normal-quality metrics.

5. Build a language-pair evaluation matrix

Collect real information needs with qualified bilingual judgments. Include same-language, cross-language and mixed-language queries, exact identifiers, rare terms and unanswerable requests. A translated copy of an English benchmark is useful but may miss how employees naturally phrase questions.

Keep translated variants of the same underlying question in the same train/test split. Otherwise a system can appear to generalize across languages while memorizing the same information need. Deduplicate translated document copies when defining relevant source identities.

Measure recall at the candidate stage, ranking quality after reranking and end-to-end successful lookup. Break results out by query language, document language and their pair. Track unauthorized exposure separately as a release-blocking failure, not a small subtraction from average relevance.

Suppose traffic is 90% English and 10% Japanese. Baseline retrieval success is 80% and 70%, giving 79% overall. A candidate improves English to 84% but reduces Japanese to 45%: overall becomes 80.1%, an apparent gain of 1.1 percentage points. Equal-language macro averaging instead falls from 75% to 64.5%. Neither weighting is inherently universal; report both and enforce agreed slice guardrails.

6. Diagnose failures at the right stage

If the relevant source is absent from candidates, inspect tokenization, encoder coverage, filters and query translation before tuning the reranker. If it is retrieved but ranked poorly, inspect judgments and cross-language reranker behavior. If users cannot understand the snippet, retrieval quality alone is not the whole usability problem.

Translation can invert negation, change units or replace a product code. Include contrast pairs where one token changes the correct source. Dense representations may favor a broadly related passage over an exact exception clause; lexical and identifier paths help preserve that distinction.

When a source is deleted or access changes, invalidate all translated and embedded derivatives through their shared source lineage. An updated original with an old translation can present contradictory instructions. Versioned manifests and explicit freshness checks prevent treating derived text as independently authoritative.

7. Roll out by supported evidence

Start with the language pairs that have adequate evaluation coverage. Shadow candidate retrieval, inspect disagreements and run a limited user trial with lookup-success measures. More clicks may mean worse results requiring more attempts, so do not equate click volume with success.

Keep a lexical fallback and a way to disable a translation or reranker branch independently. Original-language lexical retrieval may fail to recover a source written in another language, so label that degraded capability and evaluate it explicitly rather than promising equivalent cross-language recall. Roll back the compatible encoder/index/reranker bundle when necessary. An encoder upgrade requires re-embedding or a separately routed index; changing only the query encoder can make similarity scores meaningless.

Follow-ups: What if the query contains two languages and a serial number? How do permissions affect recall? Why can aggregate success improve while one language fails? What if the best source has no human translation?

Score 0–2 each for language semantics, representation choices, access-aware retrieval, worked capacity and slice-level evaluation.

Sources and next steps

The proposed enterprise architecture, evaluation counterexample and sizing are original; published benchmark results do not establish performance on this customer's languages or data. See retrieval freshness for source-update handling.

Continue your preparation

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