Design a Recommendation System
You'll learn to
- -Explain the retrieval, ranking, and re-ranking funnel and why it exists
- -Choose a training objective that is closer to satisfaction than clicks
- -Handle cold start for new users and new items
- -Reason about recall compounding across the stages of the funnel
"Design a recommendation system for a video platform" is probably the most common ML design question there is. It is a good first one to learn because nearly everything in it shows up again in the other designs in this module. Use the answer outline below, then work through each part.
An Analogy: The Bookstore Clerk
A good clerk does not read every book aloud to you. First they pull thirty books off the shelves that match your taste. Then they pick the five best for you today. Finally they adjust: not five mysteries in a row, and maybe one surprise. Those three steps are retrieval, ranking, and re-ranking.
Answer Outline
- -Clarify: what is recommended, to whom, at what scale, with what goal, and what latency.
- -Data and labels: what counts as a positive, and where negatives come from.
- -The funnel: retrieval, ranking, re-ranking.
- -Objective and features.
- -Cold start and exploration.
- -Evaluation, offline and online.
- -Failure modes and monitoring.
Clarify First
- -Scale: how many users and items? 10 million videos and 100 million daily users change the design from 10,000 items and 50,000 users.
- -Goal: more watch time, more sessions tomorrow, or more purchases? This decides the label and the guardrails.
- -Surface: a home page, a "watch next" list, or an email? Latency and freshness needs differ.
- -Constraints: new items arrive constantly, and some content must be excluded for safety or legal reasons.
Data and Labels
The signals are mostly implicit: watches, watch time, likes, shares, saves, skips. A positive might be "watched more than 50%" or "liked". Negatives are harder. An impression with no interaction is a weak negative, since the user may never have seen it. The YouTube recommendation paper from 2016 trains its ranker on expected watch time rather than clicks, to avoid rewarding misleading thumbnails. It also feeds in the age of each training example, so the model does not simply favor old popular videos over fresh ones. Both ideas are easy to mention in an interview and show that you understand what the label does.
The Funnel
- -Retrieval picks a few hundred to a few thousand candidates from millions. It uses several sources together: two-tower embedding search, videos similar to ones the user watched, trending videos, and subscriptions. It is tuned for recall.
- -Ranking scores each candidate with a rich model, often a neural network with several output heads (watch time, like, skip). A light first ranker can trim the list so the heavy one scores fewer items.
- -Re-ranking applies rules and diversity: no five videos from one creator, remove already-watched items, enforce policy, and mix in some exploration.
The code below puts rough numbers on the funnel for 10 million videos. Each stage has a cost per item and a share of the user's genuinely good videos that it keeps. The numbers are invented but the arithmetic is the lesson. Press Run and read the last column, and then the final line.
The whole funnel takes 62 ms. Running the heavy ranker on every video would take about 67 minutes per request, which shows why the funnel exists. The last column shows the price of the shortcut: recall compounds. Each stage keeps only some of the good videos, 0.85 × 0.92 × 0.90 × 0.95 is about 0.67, so 26.7 of the user's 40 favorites survive. No stage can add back what an earlier one dropped, which is why retrieval recall is the first number to check when recommendations feel poor.
Cold Start
- -New items have no history. Use content features (title, category, creator, embeddings of the video), and reserve a small slice of traffic to show them, so the system can learn how people react.
- -New users have no history either. Start with popular and trending items for their country and language, ask for a few interests during onboarding, and personalize quickly as signals arrive.
Evaluation
- -Offline: recall at the candidate cut for retrieval, NDCG or watch-time-weighted metrics for ranking, split by time.
- -Online: an A/B test on watch time and next-day retention, with guardrails such as diversity, creator reach, complaints, and latency.
- -Slices: new users, new items, and each region and language.
Failure Modes
- -Filter bubbles and feedback loops: the model learns from what it showed, so it narrows. Keep exploration and diversity.
- -Popularity bias: popular items collect more data and win more often. Re-weight or boost new content deliberately.
- -Stale models: tastes and the catalog change. Retrain often and monitor drift.
Interview Signal is part of Pro
See a real weak answer next to a real strong one for this exact topic.
Quiz is part of Pro
Test what you just read with a short quiz, and bank the XP.
Discussion0
Join the Discussion
Sign in to leave comments, reply to others, or like insights.
No comments yet. Be the first to start the thread!