The interview problem
Design personalized search for a catalog of ten million technical books and learning products. There are two million opted-in profiles and peak traffic of 1,000 queries per second. A frequent Python reader searches for Java concurrency books, but the current system keeps promoting Python titles. Improve relevance for ambiguous queries without overriding explicit intent. Include anonymous users, shared accounts, evaluation and production fallbacks.
Original ML-design practice, not a reported company interview. Scenario, architecture and calculations are original. Primary research abstracts retrieved September 27, 2026; interview date not applicable.
1. Separate eligibility from inferred preference
A person's general interests are evidence about what they might want, not instructions about their current task. Explicit selected filters, access restrictions and applicable catalog availability rules determine eligible results. Personalization ranks within that set.
If the user selects the Java topic facet, a Python-only item cannot become eligible because the profile prefers Python. A natural-language query requires more care: “Java” may be ambiguous, and a parser is not an infallible source of hard constraints. Preserve strong query matches, use confidence-aware interpretation and offer clarification when necessary.
Exact titles and identifiers should receive dedicated matching behavior. Reserve the matching item when it is eligible, rather than allowing a history feature to bury it. A product written in Japanese can be relevant to an English-interface user who explicitly asks for Japanese material; interface locale and requested content language are different signals.
Success means helping the user satisfy this query. Measure independently judged task relevance or task completion alongside clicks. More clicks can indicate either better discovery or more difficulty finding the right result.
2. Preserve query recall before personalizing rank
query + explicit filters + authorized identity
↓
query interpretation and eligibility
↙ ↘
lexical / semantic retrieval versioned profile lookup
↘ ↙
candidate union + baseline ranking
↓
intent/profile gate → bounded personal rerank
↓
final eligibility checks → result pageKeep a query-first retrieval path even for users with rich histories. Union eligible lexical, semantic and optional personalized candidates, deduplicate by item ID, and preserve strong exact matches. A perfect reranker cannot recover an item that a history-only retriever never supplied.
Start with a reliable nonpersonalized baseline. Add personalization as a separately measurable component. The gate considers query specificity, exact-match confidence, profile relevance, recency, data sufficiency and identity reliability. Sparse or unavailable history should fall back naturally to the baseline.
The gate can be a simple audited policy initially. Later, train it using evidence of when personalization improves outcomes. Predicting that someone will click personalized results is not the same as estimating improvement over the baseline. Compare both policies using appropriate randomized evidence or carefully qualified offline judgments.
Personalization should be visible enough to control: allow a user to disable it or clear history. Do not expose sensitive inferred interests in an explanation. “Based on recent searches” may be appropriate where permitted; revealing another shared-account user's history is not.
3. Work through a bounded reranking rule
As an interpretable starting point, define an original additive rule for eligible candidates:
S(q, item, user) = B(q, item) + λ × g(q, profile) × P(q, item, profile) P ∈ [−1, 1], g ∈ [0, 1], λ = 0.10
B is the baseline score, P is a bounded personalization residual, and g is one request-level gate shared by all candidates. These quantities need consistent training and scaling; adding arbitrary scores from unrelated models is not justified merely because the formula looks simple.
| Candidate | Baseline B | Residual P | Score at g = 1 | Score at g = 0.25 |
|---|---|---|---|---|
| A: stronger current-query match | 0.80 | −1 | 0.70 | 0.775 |
| B: stronger historical preference | 0.65 | +1 | 0.75 | 0.675 |
Full-strength personalization reverses these two results. A weaker gate preserves their order. Each item's perturbation has magnitude at most 0.10g, so the difference between two scores can change by at most 0.20g. A baseline gap strictly larger than 0.20g cannot reverse under this rule; equality can produce a tie.
This is a score-order bound, not a relevance guarantee. It protects no small-gap candidate and cannot make a wrong baseline correct. Explicit eligibility rules and exact-identifier handling remain separate. For an uncertain query interpretation, showing plausible alternatives can be better than confidently applying the wrong hard filter.
4. Build profiles as of the request time
Begin with compact topic preferences and recent query/item interactions. Separate session context from durable history: a user researching a new topic today should not need months of interactions to overcome an old preference. Weight evidence by relevance to the current query as well as recency.
Distinguish an explicit dislike from an item that was never displayed, and a viewed result from an unexamined impression. Cap repeated automated events and prevent a burst of accidental clicks from completely rewriting the profile. Use an event-time and ingestion-time policy so delayed events do not appear to have been known earlier than they were.
At training and evaluation time, reconstruct the profile using only information available before the search request. A profile rebuilt from the user's entire later history leaks the answer into earlier examples. A user-level train/test split alone does not prevent this temporal leakage.
Store profile version, feature definitions, permitted provenance and deletion state. Identity merges should not silently combine unrelated users. Shared-account behavior may justify a less specific profile or session-only personalization. Embeddings still encode user information; they are not anonymous simply because the raw text is absent.
Propagate opt-out and deletion through profile stores and caches. Define whether model-training records are eligible for use separately from serving preferences. Minimize retained raw histories and preserve only the evidence needed for the authorized purpose.
5. Train without confusing exposure with preference
Use query-item relevance as the foundation, then introduce profile features or learn the bounded residual. Include cold-start examples so the model remains useful when personalization is unavailable. A more complex sequence encoder is a candidate to compare, not a prerequisite for a credible first design.
Clicks are shaped by the old ranker's exposure and position choices. Treating every catalog item without a click as a negative invents observations. Log the shown candidates, ranks, model and profile versions, explicit filters and outcome window.
Limited randomized swaps among eligible, plausibly relevant candidates can provide evidence less tied to the existing ordering. Log the actual assignment probabilities. Propensity correction requires positive exposure support and a defensible observation model; it cannot infer outcomes for items that a deterministic policy never shows. Very small propensities can also make estimates unstable.
Use temporal validation and maintain independent relevance judgments grounded in the current task. Do not ask a judge to treat the same inferred profile as unquestionable ground truth. Evaluate retrieval recall separately from ranking quality so a gate improvement cannot conceal missing candidates.
6. Show how an aggregate win hides a regression
Suppose a fixed evaluation mixture contains 80% ambiguous queries and 20% exact-intent queries. The following numbers are hypothetical fractions of queries judged successful, using a fixed independent rubric:
| Policy | Ambiguous success | Exact-intent success | Overall success |
|---|---|---|---|
| Baseline | 60% | 95% | 67.0% |
| Personalize all queries | 66% | 85% | 69.8% |
| Ideal gate in this example | 66% | 95% | 71.8% |
baseline = 0.8 × 0.60 + 0.2 × 0.95 = 0.670 ungated = 0.8 × 0.66 + 0.2 × 0.85 = 0.698 ideal gated = 0.8 × 0.66 + 0.2 × 0.95 = 0.718
The ungated model gains 2.8 percentage points overall while losing ten points on exact-intent queries. The idealized gate gains 4.8 points overall by avoiding that loss. These are arithmetic scenarios, not measured model results or causal claims.
A real gate makes mistakes. Measure realized performance on independently defined query slices, not just gate classification accuracy. Also slice by profile age, history volume, anonymous status, language, new interests and shared-account risk. Freeze definitions before comparing policies; changing the query mixture can change the aggregate even when slice performance is unchanged.
For an online experiment, randomize users consistently and account for repeated queries from the same user in uncertainty estimates. Define handling for anonymous identities and shared accounts before launch. Prespecify exact-intent degradation margins and other acceptance criteria. Failure to detect harm in a small slice does not prove the guardrail passed.
Track reformulations, successful task completion and latency as well as clicks. Start with a bounded rollout and retain a baseline holdout long enough to detect feedback effects: a personalized policy changes the future history on which it will train.
7. Budget profile serving and reranking
For a simple dense representation with 128 float32 values per opted-in user:
raw vectors = 2,000,000 × 128 × 4 bytes = 1.024 GB three copies = 3.072 GB
This excludes keys, indexes, metadata, history, cache overhead and model storage. It is a vector-payload calculation, not a production memory estimate.
If the personal residual were one 128-dimensional dot product for each of 100 candidates at 1,000 queries per second:
1,000 × 100 × 128 = 12.8 million multiply-accumulates/second
A full neural reranker, candidate embedding lookup and feature assembly cost more. Benchmark realistic batch sizes, queueing, serialization and cache misses rather than treating this operation count as a throughput promise.
In an illustrative request, query retrieval takes 70 ms while profile lookup takes 20 ms in parallel. A 15 ms rerank and 5 ms final check give a 90 ms execution path: max(70, 20) + 15 + 5. This excludes other overhead and describes one timing scenario. Adding component percentile values does not establish end-to-end p95.
Use a profile deadline and a baseline fallback that already has query-relevant candidates. Avoid waiting indefinitely for a profile that is optional to correctness. Observe fallback quality and rate rather than silently hiding a prolonged feature-store outage.
8. Keep caches and fallbacks within the right identity
A shared baseline-candidate cache can include normalized query, explicit filters, locale, catalog/index version and relevant access scope. A final personalized result cache also needs the correct identity or safe personalization context, profile/model version and current consent state. A query-only key can expose or apply another person's ranking.
Revalidate volatile eligibility before serving where necessary. Permission changes and catalog removals need defined invalidation behavior; a profile-version key alone does not capture them. Logout must detach the previous user's profile from the next request on the same device. For pagination, retain a bounded result snapshot or pin the ranking/profile versions and a deterministic tie-breaker. Otherwise a profile update between pages can repeat or skip items. Recheck current access even when continuing a snapshot.
Test opt-out during an active session, profile deletion with warm caches, wrong-tenant identity, expired authorization and late-arriving events. A fallback should preserve explicit filters and access checks even if every learned component is unavailable.
Failure analysis and self-review
- Old interests overwhelm a new task: prioritize current-query evidence and limit personal influence.
- The target never enters the candidate set: preserve query-first retrieval and measure recall.
- Offline quality looks implausibly strong: check future-history leakage and exposure-conditioned labels.
- CTR rises but exact titles become harder to find: use task metrics and prespecified query slices.
- A logged-out visitor inherits another profile: fix identity lifecycle and cache isolation.
- The gate looks accurate but results deteriorate: evaluate downstream policy benefit, not only gate labels.
Follow-ups: How should a profile recover after an interest change? What if the query parser misreads a language constraint? How do you estimate personalization benefit for rarely shown items? Can a shared account safely use long-term history? What changes if candidate generation itself is personalized?
A strong answer preserves explicit intent, separates eligibility from preference, prevents temporal leakage and offers a useful baseline. An excellent answer bounds ranking changes, quantifies hidden slice regressions, connects exposure to training bias and makes identity, deletion and fallback behavior testable.
Sources and attribution
- Teevan, Dumais and Liebling: To Personalize or Not to Personalize — SIGIR, July 2008; publication abstract read. Context for variation in personalization benefit across queries.
- Ge et al.: Personalizing Search Results Using Hierarchical RNN with Query-aware Attention — arXiv submission August 20, 2019; record identifies CIKM 2018 proceedings. Abstract read. Context for history relatedness and sequential signals.
Retrieved September 27, 2026. These references motivate design questions; they do not establish current best-model status or validate the hypothetical improvements above. The catalog scenario, bounded score rule, calculations and operational contract are original practice. No company interview attribution is claimed.
Continue your preparation
Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.