Applied ML systems
Recommender systems
How feeds and stores pick a short list from millions of items. A cheap retrieval step, a careful ranker and business rules. Start here for the map.
A recommender system picks a handful of items from a catalog that may hold millions or billions, under a tight latency budget, for a user who has not typed a query. Netflix, YouTube, Spotify, Amazon, Instagram and news feeds share the same skeleton. They retrieve a shortlist cheaply, score it carefully, then apply business rules before the user sees a few cards.
The hard part is not training a neural net. It is choosing what to optimize, learning from feedback that is mostly silent, keeping popular items from drowning out the rest, and keeping a multi-stage system fresh as the catalog changes. The concepts below build that picture. Ranking covers how the second stage orders the shortlist, and news feed covers the systems side.
The funnel
- Candidate generation uses one or more retrievers, such as a two-tower model, co-visitation graphs, trending items or subscriptions. Their outputs are merged and deduplicated. The goal is high recall.
- Ranking scores each candidate with many features. The goal is to order the shortlist well.
- Re-ranking applies rules: diversity, freshness, creator fairness, age gates, ad insertion and "seen recently" filters.
A homepage usually merges several generators, such as "Continue watching," "Because you watched X," "Trending" and "Friends liked." One giant model that scores the full catalog is clean on paper, but almost never shippable at consumer scale.
Concepts in this section
Read them in order. The first two are the basis for the retrieval step.
| Step | Concept | What it answers |
|---|---|---|
| 1 | Implicit feedback and objectives | What do clicks and skips mean, and what should the system optimize? |
| 2 | Matrix factorization | How do you turn interactions into vectors and predict affinity? |
| 3 | Two-tower retrieval | How do you search millions of items in milliseconds? |
| 4 | Cold start and feedback loops | What goes wrong with new items, popular items and the model's own data? |
| 5 | YouTube recommendations, 2016 | How did one large system put these pieces together? |
Common mistakes
- Arguing about architecture before the metric. Settle the product goal first. Clicks, watch time and satisfaction lead to different systems.
- Reading logs without absences. Impressions, positions and items that were never shown matter as much as clicks.
- Assuming retrieval finds everything. Retrieval can miss good items. Invest in recall until online metrics stop moving.
Key takeaways
- Recommenders are multi-stage: cheap, high-recall retrieval, then an accurate ranker, then rules and diversity.
- Implicit feedback is abundant and noisy. Pick objectives carefully, since watch time is not clicks.
- Matrix factorization is the classic baseline. Two-tower models with ANN search are the modern retrieval default.
- Cold start, popularity bias and feedback loops often hurt more than the model architecture does.
- Large language models mostly improve item and query embeddings and content features inside this funnel. End-to-end generative ranking of the whole catalog is still early.
Further learning
Recommendation Systems course (Google)Introduction | Machine Learning | Google for DevelopersGoogle for Developers
System Design for Recommendations and Search (Eugene Yan)Breaking it into offline vs. online environments, and candidate retrieval vs. ranking steps.eugeneyan.com
Devansh Tandon of YouTube talks about adapting LLMs for video recommendations at very large scale. Watch it after the 2016 paper:
Related
Case study: news feed
How a home feed copes with fan-out, celebrities, ranking and deletes at hundreds of millions of users, and where the design gets hard.
Ranking and learning to rank
Second-stage ranking for search, feeds and ads. Learning to rank, ranking metrics, LambdaMART, CTR models, position bias and calibration. Start here for the map.
Embeddings and representation learning
Learning vectors that capture meaning, from word2vec and contrastive training to CLIP and retrieval. Start here for the map of embedding concepts.