ML System Design · Module 36 of 47 · 12 concepts · about 13 min

Design: Video Recommendations

A complete design for the home feed and 'up next' recommendations of a large video platform: what to optimise when clicks reward clickbait, candidate generation from watch histories, multi-objective ranking for watch time and satisfaction, freshness for a catalogue that grows every minute, and the feedback loops a recommender creates.

At work: One of the most studied recommendation problems, with public papers from YouTube and others. Interviewers use it to test objectives, two-stage architectures and feedback loops.

Requirements

What it is

Clipstream (the made-up video platform from module 35) wants a personalised home feed. Clarify:

  • scale: 50,000,000 daily users, about 4 home-feed opens each; hundreds of millions of videos; thousands of hours uploaded daily;
  • surfaces: the home feed (open-ended browsing) and 'up next' after a video (strongly shaped by what was just watched);
  • latency: the feed must render within about 200 ms;
  • goal: people find videos they value and come back; not just more minutes today;
  • constraints: safety and policy rules; creators, especially new ones, need a fair chance at an audience.

Why it matters

The goal statement matters more here than anywhere: a recommender optimised for the wrong thing changes what millions of people watch.

  • Home feed and 'up next' have different intents and usually get different models or features.

In the real world: Video platforms have publicly described moving from clicks to watch time, and later adding satisfaction surveys and 'not interested' signals to their objectives.

Accepting 'maximise watch time' as the goal without question. It can reward long, low-value videos and autoplay loops that people later regret.

Choosing what to optimise

What it is

Candidate objectives, and what each rewards:

  • click-through: easy to measure; rewards thumbnails that mislead;
  • watch time: rewards content people actually watch; can favour long videos regardless of value;
  • satisfaction: survey answers ('was this worth your time?'), likes, shares, and negative signals (dislikes, 'not interested', quick abandonment);
  • long-term return: whether people come back over weeks; the real goal, but slow and noisy.

Most mature systems predict several of these and combine them (module 14).

Why it matters

Each step down the list is closer to real value but harder to measure.

  • Predicting several targets and blending them lets the platform balance immediate engagement against satisfaction, and adjust the balance by experiment.

In the real world: Google's 2016 YouTube paper ranked by expected watch time precisely because ranking by clicks promoted deceptive videos.

Visual example

Computed

Five candidate videos. Blended score = expected minutes − 50 × chance of 'not interested'. The clickbait video is first by clicks and last by the blend.

Expected minutes = chance of a click × minutes watched if clicked; illustrative figures
videochance of clickexpected minutesrank by clickrank by minutesblended scorerank by blend
Shocking thumbnail, thin content12%0.09615-1.9045
30-minute cooking class5%0.7410.451
3-minute music video9%0.2724-0.234
Cricket highlights (8 min)7%0.455320.0553
Explainer on budgets (12 min)4%0.36530.062

Ranking by click probability. The table here shows how a misleading thumbnail wins on clicks and loses on every other measure.

Data and labels

What it is

The system learns from logged behaviour:

  • impressions with position and surface (module 5);
  • watches: start, duration, completion share, rewatches;
  • explicit signals: likes, dislikes, shares, subscriptions, 'not interested', 'don't recommend this channel';
  • surveys: a small random sample of users asked to rate recommended videos;
  • content: titles, transcripts, frame embeddings, categories (from module 35's pipeline).

Why it matters

Watch duration is plentiful but must be normalised: a 3-minute music video watched fully is a stronger signal than 3 minutes of a 60-minute documentary.

  • Survey responses are rare but are the closest thing to a ground truth for satisfaction, so they are used to train a satisfaction model whose predictions become a ranking signal.

In the real world: Platforms train small 'satisfaction' models on survey responses and use their predictions on all impressions, because surveys cover only a tiny share of views.

Treating every impression without a click as a dislike. Most were simply not looked at (position bias, module 7).

Practise it: Design Model Monitoring, Design a Search Ranking System

Candidate generation

What it is

Several sources, merged (module 13):

  • two-tower retrieval: a user tower over watch history, searches, demographics and context; a video tower over video ID and content; nearest neighbours in an ANN index;
  • co-watch: videos often watched after videos the user just watched (strong for 'up next');
  • subscriptions: new uploads from followed channels;
  • fresh and trending: recent uploads gaining traction in the user's region and languages;
  • exploration: a small quota of new creators and topics.

Why it matters

No single source covers everything.

  • Two-tower retrieval generalises to unseen combinations.
  • Co-watch captures sequences ('part 2').
  • Subscriptions honour explicit choices.
  • Exploration prevents the feedback loop from closing (module 22).

In the real world: Google's 2016 paper noted that predicting a held-out future watch, rather than a random held-out watch, worked much better in live tests.

# The 2016 YouTube paper framed candidate generation as "which video will be watched next?",
# a classification over millions of videos, trained with sampled softmax.
user_vec = user_tower(watch_history_embeddings, search_tokens, geography, example_age)
logits = user_vec @ video_embeddings.T          # served as nearest-neighbour search, not a full product
loss = sampled_softmax(logits, next_watched_video, num_sampled=10_000)

Training retrieval on random past watches as if order did not matter. Predicting the next watch from earlier ones matches how the system is used and avoids leaking the future.

Practise it: Design a Recommendation System, Design a Personalized News Feed

Freshness and the age of an example

What it is

A video platform's best content is often its newest, but models trained on history are biased towards old videos that have accumulated data. Remedies:

  • include the age of the training example as a feature during training, and set it to zero (now) at serving time, so the model learns how popularity changes over time and predicts for the present;
  • a fresh index and fresh-upload candidate source;
  • exploration traffic for new uploads to gather early signals quickly.

Why it matters

Without this, the model keeps recommending what was popular when its training data was collected.

  • The 'example age' trick is a simple, published fix that lets a model separate 'this video is good' from 'this video was popular last month'.

In the real world: The 2016 YouTube paper reported that adding example age as a feature let the model track the sharp popularity spikes of newly uploaded videos.

Using the video's upload age as the only freshness signal. It confuses old-but-great with stale; the training example's age is what captures the time effect.

Practise it: Design an Image Search System, Design Feature Monitoring, Debug a Production ML Model, Design a Personalized News Feed

Multi-objective ranking

What it is

The ranker scores a few hundred candidates with a multi-task model (module 12):

  • shared layers learn from all signals;
  • separate heads predict engagement (click, watch duration) and satisfaction (like, survey-predicted satisfaction, dismissal);
  • a mixture-of-experts design lets heads share some experts and not others, so conflicting tasks interfere less;
  • a small position tower learns how much position alone drives clicks during training, and is switched off at serving, to remove position bias;
  • a final score combines the heads with weights tuned by experiment.

Why it matters

Engagement and satisfaction partly conflict; a shared model with separate heads learns both efficiently.

  • Removing position bias inside the model is cleaner than correcting labels afterwards.

In the real world: Google's 2019 'watch next' paper described exactly this: multi-gate mixture-of-experts for several objectives and a shallow tower to model position bias.

Tuning the combination weights offline. Their effect on long-term return can only be measured with experiments and long-term holdouts.

Practise it: Design a Recommendation System, Design a Personalized News Feed

Re-ranking and policy

What it is

Before showing the feed:

  • diversity: limit consecutive videos from one channel or topic;
  • policy: remove or demote content that breaks rules or is borderline, regardless of predicted engagement;
  • creator fairness: guarantee some exposure for new creators via exploration slots;
  • freshness mix and already-watched filtering.

Why it matters

Item-level scores cannot express list-level goals.

  • Policy decisions must be hard rules, readable and auditable, not patterns the ranker might learn.

In the real world: Platforms have publicly described reducing recommendations of borderline content as a policy layer applied on top of ranking.

Visual example

Feed

Many sources, one multi-task ranker, policy last.

One home-feed request

  1. candidate sources, in parallel
    Two-towerNext watch
    Co-watchWatched after this
    SubscriptionsNew from followed
    Fresh and trendingNew uploads
  2. Light rankerThousands to hundreds
  3. Multi-task rankerEngagement and satisfaction
  4. BlendWeights tuned by experiment
  5. Re-rankDiversity, policy, creators

Leaving borderline content to the ranker. Engagement models often score sensational content highly; policy must be enforced outside them.

Practise it: Design a Recommendation System, Design a Personalized News Feed, Design a Real-Time Fraud Detection System, Design a Search Ranking System, Design an Ad Ranking System

Serving

What it is

Keeping the feed fast at this scale:

  • precompute user embeddings and candidate pools in batch for active users, refreshed through the day;
  • update session features live as the user watches (what was just watched matters most for 'up next');
  • rank in one batched call on GPU-backed model servers with dynamic batching (module 19);
  • fallback to precomputed candidates in retrieval order, then to regional trending.

Why it matters

Precomputation moves the heavy work off the request path; session features keep it current.

  • At tens of millions of users, small per-request savings are large in total cost.

In the real world: Large recommendation systems commonly split work into offline candidate pools, near-line updates from recent activity, and online ranking.

Recomputing the full candidate pool on every request. Most of it changes slowly; refresh it in the background.

Practise it: Design Feature Monitoring, Diagnose Training-Serving Skew, Design a Model Serving Platform, Design an ML Feature Store

Evaluation and the feedback loop

What it is

Measure at several horizons:

  • offline: per-head AUC and calibration; NDCG on held-out sessions; recall of each candidate source; by user type (new, light, heavy);
  • online: A/B tests on satisfied watch time, survey satisfaction, dismissals, and return visits; at least two weeks for novelty effects;
  • long-term holdouts for the cumulative effect of many launches;
  • ecosystem health: share of watch time going to new creators; diversity of topics per user over time.

Why it matters

A recommender shapes the data it learns from (module 22).

  • Ecosystem metrics catch narrowing that per-session metrics reward.
  • Long-term holdouts reveal whether short-term wins add up to people coming back.

In the real world: Platforms run multi-week experiments and quarterly holdbacks precisely because short-term engagement and long-term retention can move in opposite directions.

Visual example

Horizons

Short-term metrics guide; long-term ones decide.

Metrics by time horizon
horizonmetricsused for
OfflineAUC per head, NDCG, recall per sourceFiltering candidates for testing
DaysSatisfied watch time, dismissals, surveysA/B decisions
WeeksReturn visits, subscriptionsConfirming launches
QuarterHoldout comparison; creator diversityJudging the strategy

Declaring victory on a one-week watch-time lift. Some gains come from autoplay loops and fade, or cost return visits weeks later.

Practise it: Design a Large-Scale Classification Platform, Design a Predictive Maintenance System, Design a Real-Time Anomaly Detection System, Design a Recommendation System, Diagnose Training-Serving Skew, Improve a Low-Recall Model, Design a Personalized News Feed, Design a Search Ranking System

Sources and further reading

What it is

Public work this design draws on:

  • Covington, Adams and Sargin, 'Deep Neural Networks for YouTube Recommendations', RecSys 2016: two-stage design, next-watch prediction, example age, watch-time ranking;
  • Zhao et al., 'Recommending What Video to Watch Next: A Multitask Ranking System', RecSys 2019: mixture-of-experts ranking and a position-bias tower;
  • Yi et al., 'Sampling-Bias-Corrected Neural Modeling for Large Corpus Item Recommendations', RecSys 2019: two-tower retrieval with frequency correction;
  • Chen et al., 'Top-K Off-Policy Correction for a REINFORCE Recommender System', WSDM 2019: learning from logged recommendations.

Why it matters

These are some of the most cited industrial recommendation papers; knowing their key ideas is expected in senior recommendation interviews.

In the real world: Interviewers often ask 'how would you handle freshness?' or 'how would you remove position bias?'; these papers give tested, citable answers.

Interview questions: the video recommendation design

What it is

The questions interviewers ask about the video recommendation design, from the first screening call to the senior round. Cover the answer, say yours aloud, then compare.

Why it matters

Reading an idea and explaining it are different skills.

  • Each answer below is the two or three sentences an interviewer is listening for.
  • The reasoning behind each one is in the cards above. If an answer surprises you, go back to that card.

In the real world: This is among the most frequent ML design questions at media and social companies, and interviewers often know the public papers well.

Q: Why not rank by click probability?

It rewards misleading thumbnails. Rank by expected watch time and satisfaction signals, with penalties for dismissals, combined from a multi-task model.

Q: How do you generate candidates?

Two-tower retrieval trained to predict the next watch, co-watch for sequences, subscriptions, fresh and trending uploads, and an exploration quota, merged before ranking.

Q: How do you keep recommendations fresh?

Train with the age of each example as a feature and set it to zero at serving, keep a fresh index and fresh-upload candidates, and explore new uploads.

Q: How do you remove position bias?

A shallow position tower during training that absorbs the effect of position, dropped at serving, or inverse-propensity weighting from randomised data.

Q: How would you measure success?

Satisfied watch time, survey satisfaction and dismissals in multi-week A/B tests; return visits and creator diversity in long-term holdouts.

Q: What feedback loops worry you?

Narrowing onto popular videos and topics, and creators never getting an audience; counter with exploration, diversity rules and ecosystem metrics.

Optimising one engagement number with no mention of satisfaction or feedback loops.

Exercise: compare objectives

What it is

A short build that uses this module's ideas. Write it yourself before looking anything up; the checks at the end tell you whether it works.

Why it matters

An idea you have only read fades in a week.

  • Building it once, even in fifty lines, is what makes it yours.
  • Interviewers can tell the difference between someone who has read about a loop and someone who has debugged one.

In the real world: Objective-comparison analyses like this are how recommendation teams argue for changing what they optimise.

Your task. Train ranking models on a public dataset with watch or rating data under different objectives and see how the top recommendations change.

Steps

  1. Use a public dataset with engagement duration or ratings (for example KuaiRec, MovieLens with ratings as a satisfaction stand-in).
  2. Build a candidate set per user from a popularity and co-occurrence source.
  3. Train three rankers: predicting click or interaction, predicting duration-weighted interaction, and a multi-task model with an extra satisfaction head.
  4. For a sample of users, compare their top 10 under each model: average predicted duration, average satisfaction and number of distinct categories.
  5. Write a paragraph on which objective you would ship and why.

You are done when

  • You can show at least one item that rises under click optimisation and falls under satisfaction.
  • Your recommendation names a guardrail and a long-term metric.

Stretch. Add an example-age feature and test whether predictions for recent items improve on a later time period.