09 · Interview preparation

Walkthrough, video recommendation

15 min read

The second walkthrough takes a video recommendation prompt through the six interview phases. The dialogue is written out, the candidate’s options are graded and the whiteboard is redrawn where it changes. A two-stage recommendation system first finds a few hundred likely videos out of hundreds of millions, then ranks that shortlist with everything it knows about the moment. The two stages exist because of arithmetic, and the walkthrough shows that arithmetic along with the two problems every recommender has to face, which are items with no history and the way the model’s own placements distort what it learns.

The prompt and an everyday picture of it

The interviewer opens with the prompt. “Design the home feed for a video app. When someone opens the app they should see twenty videos chosen for them, and it should feel instant.” That is all the candidate is given, and the clock starts.

A good bookshop assistant does this in two moves. When a regular customer walks in, the assistant first pulls a shelf of thirty or forty books that might suit them, based on what they bought before. Only then does the assistant look at the customer, the weather and the time of day to pick the three to put in their hands. Pulling the shelf is the candidate stage, picking the three is the ranking stage, and the assistant never considers every book in the shop because there is no time.

Two things about the shop do not carry over. The shop holds ten thousand books while the app holds 800 million videos, so the first move has to be done by a machine ahead of time. And the assistant does not learn from where she placed books on the table, while the app does, because people click what is at the top of the feed whether or not it was the best choice, and that distorts what the model learns next.

Phase 1, framing and scope

The candidate confirms the surface first. “Is this the feed on opening the app, rather than the related videos beside one that is playing or the next video in autoplay?” The interviewer confirms it is the opening feed. The candidate asks how many videos exist and how many people open the app, and the interviewer gives 800 million videos and asks the candidate to assume the rest.

The candidate sets assumptions and converts them. “I will assume 50 million people open the app each day, about ten times each, which is 500 million requests a day or roughly 5,800 a second, with peaks maybe three times that. I will take instant to mean the feed appears within 200 milliseconds, and I will treat about 100 of those as mine, with the rest for the network and the phone.” The interviewer accepts both numbers and the candidate writes them in the corner of the board.

The candidate then states the task. “For each candidate video, the model predicts the probability that this person watches it for at least 30 seconds without skipping, and the feed is the twenty with the highest predicted value, with a few rules on top such as no two videos from the same creator.” The interviewer asks why 30 seconds rather than a click, and the candidate says a click rewards misleading thumbnails while a 30 second watch is closer to the person having wanted the video. It is also observed within a minute, so labels arrive fast.

Phase 1, framing and scope
GradeWhat the candidate saysWhy it earns that grade
Weak“I would train a deep model on watch history and score the videos for each user.”No surface, no target and no numbers, and scoring the videos hides the fact that there are 800 million of them.
Good“Predict the chance of a 30 second watch for each candidate and show the top twenty.”A clear target and output, but nothing about how many requests arrive or how candidates are found.
Strong“Same target, and at 5,800 requests a second against 800 million videos I need a cheap stage to find candidates before anything is scored.”The target is stated and the arithmetic that forces two stages is on the table in the first minutes.

Phase 2, the pipeline sketch and the funnel arithmetic

The candidate draws the two stages and justifies them with numbers. “If I scored every video for every request, that is 800 million scores times 5,800 requests a second, which is about 4.6 trillion scores a second, and no fleet does that. If a first stage can find 500 likely candidates per request, ranking is 500 times 5,800, about 2.9 million scores a second, which a few dozen machines can handle. So the first stage has to be cheap and the second can be expensive.”

The interviewer asks how the first stage can be cheap when it still has to look at 800 million videos. The candidate explains that each video is turned ahead of time into an embedding, meaning a short list of numbers that places similar videos near each other. A search structure over those numbers can then return the few hundred nearest to a person’s own list of numbers in a few milliseconds. The expensive part, computing the embeddings, runs once a night rather than once a request.

The candidate adds the learning path. What was shown and what was watched is logged, and those logs train the next version of the ranking model. The whiteboard at the end of this phase is below, and its boxes are still labels rather than choices, since the interviewer has not asked for a component yet.

The whiteboard after the sketch phaseApp opens, Person and time of day. Candidate finder, About 500 videos. Ranking model, Score each candidate. Feed of twenty, Shown to the person. Video embeddings, Computed nightly. Training, Learn from watches. Watch logs, Shown, watched, skipped. App opens connects to Candidate finder. Candidate finder connects to Ranking model. Ranking model connects to Feed of twenty. Video embeddings connects to Candidate finder through nightly. Feed of twenty connects to Watch logs through shown and watched. Watch logs connects to Training. Training connects to Ranking model through new model. The top row is the expensive part, and everything dashed happens hours away.The whiteboard after the sketch phaseAnswering a requestDone ahead of timeNightlyShown and watchedNew modelApp opensPerson and time ofdayCandidate finderAbout 500 videosRanking modelScore eachcandidateFeed of twentyShown to thepersonVideo embeddingsComputed nightlyTrainingLearn from watchesWatch logsShown, watched,skipped
The top row is the expensive part, and everything dashed happens hours away.On a narrow screen, scroll the figure sideways to see every step.
500,000,000 requests / 86,400 seconds ≈ 5,800 requests/s
5,800 × 800,000,000 videos ≈ 4.6 trillion scores/s, which no fleet does
5,800 × 500 candidates ≈ 2.9 million scores/s, which a few dozen machines do

Phase 3, data, features and position bias

Asked what a training example is, the candidate defines it precisely. “One example is one video shown to one person at one moment, with the information available at that moment, and a label that is one if they watched for 30 seconds and zero otherwise. Only shown videos can be examples, because I cannot know what someone would have done with a video they never saw.” The interviewer asks how rare the ones are, and the candidate assumes people engage with fewer than one in fifty videos they see, so the positives are about two percent and the training set must keep all of them and sample the zeros, with the probabilities corrected afterwards.

Features are organised by source. The person brings their watch history, summarised as an embedding, plus language and country. The video brings its own embedding, its length, its age in hours and its creator. The moment brings the time of day, the device and what has already been watched in this session, which matters because someone who has watched three cooking videos in a row is not the same person as their monthly average. The candidate also adds one feature that compares the person and the video directly, the similarity between the video’s embedding and the person’s recent watches.

The interviewer asks whether the label can be trusted. The candidate raises position bias. “People watch what is at the top of the feed far more than what is at position twenty, whatever the video is. If I train on raw labels, the model learns that videos the old model placed at the top are good, which is partly true and partly the position talking.” The fix the candidate offers is to give the model the position as an input during training and set it to a fixed value, such as position one, when serving. The model then learns how much of each watch was the position and removes it at prediction time.

Ignoring the bias and treating every watch as equal is the weak answer here, and naming it with the position feature as the fix is a good one. The strong answer adds that the bias also hides good videos that were never shown high, so a small share of the feed should be given to candidates the model is unsure about, which is the exploration that cold start needs as well.

How the feed’s own placements distort the labelsModel ranks feed, Top slots chosen. Top slots watched, Whatever is there. Watches as labels, Position not recorded. Next model learns, Rewards old placements. The green box records the position, which separates the video from its slot.How the feed’s own placements distort the labelsModel ranks feedTop slots chosenTop slots watchedWhatever is thereWatches as labelsPosition not recordedNext model learnsRewards old placements
The green box records the position, which separates the video from its slot.On a narrow screen, scroll the figure sideways to see every step.

Phase 4, modelling and cold start

The candidate gives each stage a baseline and an upgrade. “For candidates, the baseline is the most watched videos in the person’s country over the last day, which needs no model and is what new users see anyway. The upgrade is a two-tower model, meaning one small network that turns the person into a list of numbers and another that turns a video into a list of the same length, trained so the two lists are close when the person watched the video. The video side is computed nightly and searched with an approximate nearest neighbour index, which gives up a little accuracy for a lookup in a few milliseconds.”

For the ranking model the baseline is gradient boosted trees, a model built from many small decision rules that handles mixed features well and is cheap to run, trained with cross-entropy, a loss that rewards probabilities close to what happened, on the 30 second label. The upgrade is a neural ranker with several outputs, predicting the watch, a like and a skip at once, combined by weights the product team chooses. The interviewer asks why not start with the neural ranker, and the candidate says the trees give a measured number in a week and the neural model has to beat that number to earn its cost.

The interviewer asks about a video uploaded an hour ago. The candidate names the problem before offering a fix. “A new video has no watches, so the two-tower model has nothing to place it by, and the ranking model has never seen it. That gap is what people call cold start.”

The candidate proposes three things together. The video tower takes content inputs, such as the title, the thumbnail and the creator, so a new video gets a rough embedding before anyone watches it. A small share of each feed, perhaps one slot in twenty, is reserved for new videos matched on content, so they collect their first watches. And the embeddings refresh more often than nightly for videos under a day old.

New people are the other half of cold start. The baseline of popular videos by country and language handles the first session, and the candidate adds that asking a new person to pick three interests on sign-up gives the person tower something to work with from the first request. At this phase the whiteboard gains sizes on the two stages, which the funnel below shows.

The two stages with their sizesWhole catalog, 800 million videos, embedded nightly. Candidates, About 500 nearest neighbours. Feed, Twenty, ranked in context. The expensive model runs only in the bottom band, on 500 items.The two stages with their sizesWhole catalog800 million videos, embedded nightlyCandidatesAbout 500 nearest neighboursFeedTwenty, ranked in context
The expensive model runs only in the bottom band, on 500 items.On a narrow screen, scroll the figure sideways to see every step.
Phase 4, modelling and cold start
GradeWhat the candidate proposesWhy it earns that grade
WeakOne neural model that scores every video for every request.Ignores the arithmetic from the sketch and has no plan for the 4.6 trillion scores a second it implies.
GoodNearest neighbour candidates from a two-tower model, then a tree-based ranker.Two stages with a cheap first stage and a measured baseline, but new videos and new people are not mentioned.
StrongThe same two stages, with content inputs in the video tower, a reserved slot for new videos and a popularity baseline for new people.Cold start is handled on both sides without a separate system, and the reserved slot doubles as the exploration that position bias needs.

Phase 5, evaluation and serving

Measurement comes next, and the candidate gives each stage its own metric. “For the candidate stage I measure recall at 500, meaning the share of videos people watched that appeared somewhere in the 500 candidates, because a video the first stage misses can never be ranked. For the ranking stage I measure precision at twenty, the share of the twenty shown that were watched, and normalised discounted cumulative gain, which rewards putting the watched videos near the top rather than anywhere in the twenty.” The interviewer asks what the candidate expects, and the candidate says recall at 500 around 0.6 for a first two-tower model is a reasonable assumption, labelled as such.

Offline numbers are checked against online ones. The candidate proposes an experiment in which a small share of people get the new ranker, with watch time per session as the main measure and skip rate, dislikes and the share of videos from small creators as guardrails, meaning numbers that are not allowed to get worse. The interviewer asks why guardrails, and the candidate says a ranker can raise watch time by showing the same ten viral videos to everyone, which empties the feed for creators and bores people within a month.

Serving fits the 100 milliseconds the candidate claimed. Looking up the person’s features takes about 15 milliseconds, the nearest neighbour search about 25, ranking 500 candidates in one batch about 40, and assembling the feed with its rules about 20. The interviewer asks what absorbs the peak of 17,000 requests a second. The candidate adds a cache in front of the pipeline that keeps a person’s feed for a few minutes, so someone who opens the app three times in ten minutes costs one computation, and says the cache also returns yesterday’s popular videos if the ranker is down.

The 100 milliseconds the candidate ownsFeatures, Look up the person, 15 ms. Candidates, Nearest neighbour search, 25 ms. Ranking, Score 500 in one batch, 40 ms. Assemble, Rules, then cache, 20 ms. Ranking gets the largest share because its cost grows with the candidates.The 100 milliseconds the candidate ownsFeatures15 msLook up the personCandidates25 msNearest neighbour searchRanking40 msScore 500 in one batchAssemble20 msRules, then cache
Ranking gets the largest share because its cost grows with the candidates.On a narrow screen, scroll the figure sideways to see every step.

Phase 6, monitoring and deep dives

The interviewer asks what the candidate watches after launch, and the answer sorts the signals by speed. “Within the hour I watch the share of feeds served from the cache and the response time at the slowest one in a hundred requests. Within the day I watch watch time per session and the skip rate against last week. Within the week I watch coverage, meaning how many distinct videos appeared in feeds at all, because a falling number means the feed is collapsing onto a few popular videos.” The interviewer asks what the candidate does when coverage falls, and the candidate raises the exploration share and checks whether the retrain has been learning from its own placements.

Freshness comes from the stream of engagement events, which arrive continuously, so the ranking model retrains daily on the last few weeks of watches. The candidate adds that a daily retrain is only safe with a check that the new model matches the old one on data kept aside for testing, followed by a short period on a small share of traffic before it takes over. The interviewer asks about a trend that appears in an afternoon, and the candidate says the nightly embeddings are too slow for that. The candidate proposes a small live signal, the video’s watch count in the last hour, as a ranking feature that the daily model can use without being retrained.

The whiteboard at the end of the round has the cache in the serving path, the stream feeding a daily retrain and a monitoring box between them. The last minutes go to a deep dive about the reserved slot, where the interviewer asks how the candidate would know the exploration is worth its cost, and the candidate proposes counting how many of the videos that became popular this month got their first thousand watches through that slot.

The whiteboard at the end of the roundApp opens, Person and time of day. Feed cache, Recent feeds. Candidate finder, Embedding search. Ranking model, Fresh context. Daily retrain, Last weeks of watches. Video embeddings, Nightly batch. Monitoring, Watch time and coverage. Engagement stream, Clicks, watches, skips. App opens connects to Feed cache. Feed cache connects to Candidate finder. Candidate finder connects to Ranking model. Ranking model connects to Engagement stream through shown and watched. Engagement stream connects to Monitoring. Monitoring connects to Daily retrain. Video embeddings connects to Candidate finder through nightly. Daily retrain connects to Ranking model through new model every day. The cache now sits in front of both stages.The whiteboard at the end of the roundAnswering a requestAround the requestShown and watchedNightlyNew model every dayApp opensPerson and time ofdayFeed cacheRecent feedsCandidate finderEmbedding searchRanking modelFresh contextDaily retrainLast weeks ofwatchesVideo embeddingsNightly batchMonitoringWatch time andcoverageEngagementstreamClicks, watches,skips
The cache now sits in front of both stages.On a narrow screen, scroll the figure sideways to see every step.

What mid, senior and staff candidates are expected to show

A mid-level candidate is expected to reach two stages with a reason, a 30 second target, a training example defined as a shown video, a baseline and an upgrade for each stage, and offline metrics for both. Doing the funnel arithmetic aloud and fitting the serving steps into the deadline puts a mid-level candidate near the top of that band.

A senior candidate is expected to raise position bias and cold start before being asked, and to connect them, since the reserved exploration slot answers both. A senior candidate also gives each stage its own metric, names guardrails for the online experiment, and explains why the tree-based ranker is the right first model even though a neural one will replace it.

A staff candidate is expected to talk about the system a year from now. That includes how the feed can collapse onto popular videos and what coverage monitoring and exploration do about it, how a daily retrain on the model’s own placements compounds the bias unless position is recorded, how creators respond to the ranker and what that does to the catalog, and how to show the product team the cost of the weights they choose between watches, likes and skips. A staff candidate spends the least time on the model architecture of the three.

Interview questions

A video was uploaded ten minutes ago and has no watches. How does it ever reach a feed?

It reaches a feed through its content rather than its history. The video side of my two-tower model takes the title, the thumbnail and the creator as inputs, so a new video gets a rough embedding the moment it is uploaded, and it can be found as a candidate for people whose embedding is near that content, even before anyone has watched it.

I would also reserve about one slot in twenty in each feed for videos under a day old, matched on that content embedding, so new videos collect their first few hundred watches quickly. After that the normal signals take over, and I would refresh embeddings for young videos every hour rather than nightly so the first watches count sooner.

Your ranker’s offline precision at twenty improved, but watch time fell in the online test. What happened?

The offline test set only contains videos the old model chose to show, so a new ranker that agrees more with the old model scores well offline while showing people the same things. Online, the people got a feed that was more of what they had already seen and watched less of it.

I would check the guardrails first, especially coverage and the skip rate, and then look at whether the new ranker is leaning harder on position or popularity features. The fix is usually to record position with every label, add a little exploration to the feed so the test set contains some surprises, and judge the ranker by the online experiment rather than by the offline number alone.

You said the position in the feed should be a training input. Why does the model need it?

People watch what is near the top of the feed far more than what is near the bottom, whatever the video is, so a label that says watched is partly about the video and partly about the slot it sat in. If the model never sees the slot, it credits the video for the slot and learns to repeat whatever the old model put at the top.

Giving the model the position during training lets it learn how much of each watch was the slot. At serving time I set the position input to the same value for every candidate, usually position one, so the scores compare the videos on their own and the slot effect is removed. The cost is one extra feature, and the gain is a model that can promote a good video the old model buried.

What to practice next

These problems let you build the popularity baseline new users see, pick the top items from a set of scores, and measure a ranked list with precision and recall at a cutoff.