Learning path: Prepare for ML Engineer Interviews · Step 6 of 13
ML System Design Interview: A Recommendation Feed, From a Score to Beat to Online Guardrails
How to answer "design a recommendation feed": a score to beat (popular 39 of 500, clicked-together 148 of 500), two stages, freshness, cold start dropping to 33, a feedback loop you break on purpose, and online metrics with guardrails.
What you will learn
- Set a score to beat by hiding each user's last click, with popular items as the baseline
- Explain the two-stage feed and the trade-off between a wide first stage and a sharp second one
- Handle freshness, cold start and the feedback loop, and say what each fix costs
- Judge a new feed online with click rate plus guardrails
Before you start
- The ML System Design Framework
- Recommendations, Part 1: Two Stages, Candidates Then Ranking
The question: design a recommendation feed. You go through the eight steps from the ML system design framework in order, as always. But every question has a few hard parts, and that's where the interviewer pulls. For a feed they are: a score to beat, two stages, freshness and cold start, the feedback loop, and online metrics. So we'll spend our time on those.
The click numbers below come from a small simulation with synthetic clicks. The mechanics are built in code in the Recommendations series.
Start with a score to beat
First we need a way to score a feed before anyone sees it. So we hide each user's last click and check whether it lands in our top ten.
Showing everyone what's most popular gets 39 hits out of 500 users. Using items that get clicked together with what this user already clicked gets 148. To be fair, the synthetic data was built with five interest groups, so there was a pattern to find; your own data may not be so kind. But now you have a number to beat, and popular is your baseline. Offline metrics for ranking are in Recall@k and nDCG.
Two stages, like a bookshop
There are more books in the world than anyone can look at. So the shop's buyer picks 500 books for the shop, quickly, without knowing you. Then the assistant talks to you and picks three. That's slow and careful, and it only works because the buyer has already cut the pile down.
A feed is the same. The first stage is fast and simple and gets us down to a few hundred (candidate generation). The second stage is a heavier model that ranks those few hundred, and we show the top ten.
The trade-off to say out loud: if the first stage misses an item, the second stage never sees it. So the first stage has to be wide, and the second has to be sharp.
Freshness
Think of the waiter who has today's specials ready; he didn't work them out while you were sitting down. A feed can do the same: prepare lists ahead of time, so the answer comes back fast.
But a list made last night knows nothing about this morning. A new item has no clicks yet, and it can't get clicks if it's never shown. So you mix: keep the prepared list, add a small slot for new items, and adjust using what this user just did. Say the price: fresher means more work per request. How fresh it has to be depends on the product. News needs minutes; a film catalogue can wait.
Cold start
A new user walks in, and we know nothing about them. In the simulation we pretended we knew nothing about these users, and the hits fell from 148 to 33, about what popular got. That makes sense: with nothing to go on, popular is all we have.
So that's the waiter's safe suggestion for first-timers: don't leave the plate empty, show something most people like. Then learn quickly; their first few clicks start to change the list. New items have a cold start too, and for them you use what the item is about, since there aren't any clicks yet.
The feedback loop
This is the trap that's special to a feed. The model learns from clicks, but people can only click what we showed them. So an item gets shown, it gets clicked, the model learns it's good, and it gets shown even more. Meanwhile a better item that was never shown collects no clicks, so it looks bad, and the feed slowly narrows.
So you break the loop on purpose: keep a small share of the slots for trying things out, and record what was shown as well as what was clicked. It costs a few clicks today, and you say that out loud. (This one is a picture of the idea; it wasn't measured in the simulation.)
Online metrics and guardrails
That 148 is offline: it tells us about past clicks, on a list nobody actually saw. What we really want to know is what happens with real people. So we split users into two groups, old feed and new feed, and compare (A/B Tests for Models).
Start with click rate. But clicks can mislead: a feed full of loud headlines gets clicks and annoys people. So add guardrails. Do people come back? Do they hide items? Is the feed getting narrower? A new feed only wins if clicks go up and the guardrails hold.
Follow-ups and a rubric
- "Clicks went up, but people come back less. What do you do?" Trust the guardrail, and find out what the clicks were hiding.
- "The ranking service goes down. What does the user see?" Popular. It loses a lot, but nobody is stuck on an empty page (serving with a popular fallback).
- "How do you know the feed isn't just showing what it showed yesterday?" Look at the slots you kept for trying things out.
An example rubric, out of 10: five rows (score to beat, two stages, freshness and cold start, feedback loop, online metrics), each 0 if skipped, 1 if only named, 2 if you said why and what it costs. Every company scores in its own way.
Recap
| Hard part | The point to land |
|---|---|
| Score to beat | Hide the last click; popular is the baseline |
| Two stages | A wide first stage, a sharp second one |
| Freshness, cold start | Mix in new items, start new users on popular, and say the cost |
| Feedback loop | Break it on purpose with a few trial slots |
| Online metrics | Clicks up and guardrails holding |
Try it yourself
Take a feed of short videos, and say out loud what changes for freshness and cold start.
Related course on Udemy
Machine Learning Engineer: From First Model to ML Engineer
Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (paid course, opens in a new tab)Related posts
The ML Engineer Interview Loop: Five Rounds, What Each One Looks For, and a Simple Rubric
The rounds you go through for one ML engineer job: recruiter screen, coding, ML depth, ML system design and behavioural. What each round looks for, the follow-up it brings, and a four-check rubric for your own answers.
The Answer Framework for Technical Interviews: Five Moves, Scored Out of 24
Good interview answers share one shape: a 30-second answer, the mechanism, the trade-off, the metric and the failure test. Worked on one question about a batch job starving everyone else, with a 24-point example rubric.
From Symptom to Pattern: How to Answer "Which Pattern Would You Use?" in an Interview
Start from what you can see, not from the pattern you know. A four-step rule (symptom, cost, metric and failure test, ship first), a symptom table, one worked answer for 429s at peak, and the trap of using a prompt as a lock.
The ML System Design Framework: Eight Steps, in Order, on a Spam Filter
One repeatable route through any ML system design question: goal, metric, data, features, model, serving, monitoring and failure. Worked on an email spam filter, with the follow-ups and a three-check rubric.