The interview problem
A learning-video service ranks candidates by predicted usefulness. Users complain that the first page repeats the same topic and creator. Design a reranker that returns ten useful videos with more variety, a maximum of two videos per creator, and topic coverage when suitable candidates exist. Explain infeasible constraints, latency and how to measure improvement.
Original ML-design practice, not a reported company interview. All data and calculations are hypothetical. Primary technical references retrieved September 27, 2026.
Quick answer
Recommendation diversity reduces redundant results while retaining useful items. MMR trades a relevance score against similarity to selected items; hard rules such as creator caps must be enforced separately. Check whether the candidate pool can fill the requested list before tuning a diversity weight.
1. Define which variety matters
Distinguish topical diversity within one list, creator concentration, novelty to this user, and catalog coverage across the population. They are different objectives. Ten creators repeating one lesson are creator-diverse but semantically repetitive. Ten unrelated videos can be diverse yet useless. A new upload is not necessarily novel to a viewer who has seen equivalent material.
Here safety, availability and authorization are hard eligibility rules. The two-per-creator cap is also hard for this product contract; return fewer results rather than silently violate it. Topic coverage is a soft preference subject to usefulness and available supply. For a narrowly specified request such as “binary search exercises,” do not force unrelated topics merely to satisfy a generic coverage target.
Define usefulness scores on a stable scale and validate them by topic and user segment. A score threshold is a model decision, not proof of actual usefulness. Record why candidates were excluded so inadequate supply can be distinguished from overly strict policy.
2. Preserve candidate variety before reranking
user intent + recent exposure
↓
multiple candidate sources → eligibility + canonical deduplication
↓
usefulness model + creator/topic metadata + content embeddings
↓
constraint-aware greedy reranker → final eligibility check → displayed slate
↓
exposure log + outcomes + constraint/fallback diagnosticsRetrieve more than ten candidates from complementary sources. If retrieval supplies only one topic, downstream reranking cannot invent another. Measure eligible supply by creator and topic before changing reranker weights. Canonicalize reuploads and near-identical lessons; otherwise duplicate videos can evade creator caps and inflate apparent novelty.
Keep embeddings, taxonomy versions and score-model versions compatible. Use a snapshot of recent exposure to penalize repeated recommendations, with a declared consistency limit when a user opens multiple devices. Log actual displayed positions and visibility, not just the server's proposed order. A candidate sent below the fold is not equivalent to a viewed recommendation.
3. Balance relevance and redundancy
One practical baseline is maximal marginal relevance (MMR): at each step choose an eligible candidate maximizing λr(i) − (1 − λ) max s(i,j), where j ranges over already selected items. Here 0 ≤ λ ≤ 1, r is usefulness, s is redundancy similarity, and both scores are scaled to [0,1]. For an empty slate, define the redundancy term as zero. Break ties deterministically by usefulness and then stable item ID; at λ = 0 all initial marginal scores tie. λ near one emphasizes usefulness; smaller λ penalizes redundancy more. This is our stated convention, not a promise that a vendor parameter with a similar name uses the same direction.
Before scoring, exclude candidates whose creator has reached the cap. Maintain each remaining item's maximum similarity to the selected slate and update it after each addition. This is a greedy heuristic. Do not claim it finds the globally optimal constrained list or attach an approximation guarantee without proving the required objective and constraint assumptions.
Similarity must represent the repetition users dislike. An embedding trained for broad topic matching may penalize complementary lessons on the same topic or miss visually different reuploads. Validate pairs with human judgments and include creator, series and duplicate signals where appropriate. A hard duplicate rule can be more reliable than hoping a similarity penalty removes duplicates.
4. Calculate a three-slot slate
Use a smaller exercise with a one-per-creator cap and λ = 0.7. Candidates are:
| Item | Creator | Topic | Usefulness |
|---|---|---|---|
| A | X | Databases | 0.95 |
| B | X | Databases | 0.94 |
| C | Y | Databases | 0.90 |
| D | Z | Networking | 0.84 |
| E | W | Storage | 0.80 |
A is chosen first because the empty-slate penalty is zero. B is then excluded by the creator cap. Treat the following pair similarities as symmetric illustrative redundancy scores, not measurements from a particular embedding model. Suppose s(A,C)=0.9, s(A,D)=0.2 and s(A,E)=0.1. The next scores are C: 0.7×0.90−0.3×0.9=0.36; D: 0.7×0.84−0.3×0.2=0.528; E: 0.7×0.80−0.3×0.1=0.53. E narrowly wins.
For the third slot, let s(C,E)=0.15 and s(D,E)=0.3. C's maximum similarity remains 0.9, giving 0.36. D's maximum becomes 0.3, giving 0.498. Choose D. The final slate is A, E, D, covering three topics and three creators.
A relevance-only ranking respecting the same creator cap would choose A, C, D. Its usefulness sum is 2.69 versus 2.59 for A, E, D: a decrease of 0.10, approximately 3.72%. This is a difference in model scores, not an observed loss in satisfaction or a causal estimate of engagement. User utility can depend on the whole slate and position.
Using mean pairwise dissimilarity 1−s as one diagnostic, A,C,D has similarities 0.9,0.2,0.25 when s(C,D)=0.25. Its diversity is 1−1.35/3=0.55. A,E,D has similarities 0.1,0.2,0.3 and diversity 1−0.6/3=0.80. The increase shows what this metric rewards; it does not independently establish product value.
5. Handle infeasible coverage explicitly
Suppose an experiment asks for at least three topics in a ten-item list, but only two topics have eligible candidates above the usefulness threshold. The target is infeasible. Return a useful list with an explicit unmet-coverage diagnostic rather than lowering safety requirements or fabricating topic labels. Additional retrieval may help if it has a bounded latency budget and genuinely different supply.
Even when suitable candidates exist, greedy choices can make future constraints impossible. Imagine a two-slot slate requiring topics P and Q with a one-per-creator cap. Candidates are P from creator X at 0.99, Q from X at 0.90, and P from Y at 0.89. Choosing the highest-scored P first blocks the only Q. The feasible slate is Q from X plus P from Y.
If coverage is made hard, use feasibility-aware lookahead, bounded search or an appropriate constrained optimizer for the actual constraint family. Document the fallback when no solution exists. For the requested soft coverage preference, a coverage bonus or reranking repair can be simpler, but must still preserve creator caps and eligibility. Do not present a soft penalty as a hard guarantee.
6. Bound serving work and degradation
For N=500 candidates, K=10 output slots and 128-dimensional embeddings, maintaining maximum similarity incrementally takes at most roughly N×K=5,000 pair comparisons, or 640,000 scalar multiplications for straightforward dot products. This is an operation-count estimate, not a latency benchmark. Normalization, memory access, metadata joins and model scoring also consume time.
Precomputing all unordered pairs would involve 500×499/2=124,750 comparisons, about 25 times as many as the rough incremental bound. Fetch embeddings in one bounded batch and reuse them within the request. Set an end-to-end deadline and measure tail latency under realistic candidate sizes.
If embeddings are unavailable, use relevance ranking with creator caps and canonical deduplication. Report that semantic diversification was skipped. Do not block all recommendations unless the product contract requires semantic diversity. Conversely, missing eligibility or authorization evidence is not a reason to return an unchecked item. Apply a final filter and refill only from candidates that still satisfy the constraints.
7. Evaluate useful variety over time
Offline, measure usefulness ranking, within-list similarity, creator concentration, topic coverage, repeated exposure and eligible-supply failures. Evaluate the trade-off curve across λ and candidate depth. Separate broad discovery sessions from focused learning tasks. Use stable item and creator identities; splitting one creator into multiple aliases should not count as progress.
Run a user-randomized experiment so the same person does not alternate policies unpredictably. Track meaningful consumption, explicit satisfaction and continuation over an agreed period, with abandonment, repetition complaints and latency as guardrails. Analyze uncertainty at the randomization unit. Shared creator incentives or a model retrained on both experiment arms can create interference; freeze shared learning where practical for the initial test and state which longer-term effects remain unmeasured. Do not count every recommendation impression from one user as an independent experimental unit.
Population catalog coverage can increase while each user's experience remains repetitive, or while a few items receive nearly all visible positions. Report exposure distribution and position alongside counts of distinct items. Novelty alone is easy to improve by showing obscure irrelevant videos. Google's cited research motivates evaluating relevance and diversity together; our launch decision requires evidence of useful variety under the actual product objective.
Log candidate sources, eligibility decisions, selected order, model/policy versions and actual exposures. Historical clicks collected under the old policy are selected by that policy; do not interpret unshown candidates as disliked. Long-term learning and creator responses may differ from a short experiment, so define follow-up monitoring and rollback conditions.
8. Follow-ups and self-review
Follow-ups: Does MMR ensure three topics? No. Can creator caps improve semantic diversity? Sometimes, but different creators may repeat content. Can a reranker fix one-topic retrieval? Not without new candidates. Is diversity equivalent to exploration? No; a deterministic reranker can diversify known items without learning about uncertain ones. What if the user wants one specialist creator? Make that intent an explicit product-policy case rather than silently overriding the default cap.
Score 0–2 each for precise diversity definitions, correct worked reranking, feasibility and hard-constraint handling, bounded serving with honest fallbacks, and an evaluation that preserves usefulness. Full marks require separating a better diversity metric from a better user experience.
The candidate pool can make a list impossible
Suppose the request is for ten recommendations, with at most two items per creator. The retrieved pool contains five items from creator A, three from B and one from C. Even though nine candidates exist, the maximum feasible output is min(5,2) + min(3,2) + min(1,2) = 5.
No MMR weight can turn those candidates into ten valid results. Retrieve more eligible items from additional creators, use a documented fallback pool, or return a shorter list. Relaxing a hard creator rule is a product-policy change, not a numerical tuning step.
This sum is an upper bound when other constraints also apply; eligibility, language or topic restrictions can reduce feasibility further. Record short-list frequency and the limiting constraint alongside relevance and diversity metrics. A system that silently pads duplicates may look healthy on response length while violating its stated contract.
Sources and next steps
- OpenSearch: native MMR — iterative relevance/diversity reranking; published November 17, 2025.
- Google Research: unified accuracy and diversity metrics — joint evaluation of recommendation quality.
The workload, slate calculations, infeasibility counterexample and operational design are original. Continue with video recommendation architecture.
Continue your preparation
Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.