How is a recommendation feed designed?
A recommendation feed picks a handful of items for each user from a catalog far too large to score in full. Production systems split the work into stages: retrieval narrows millions of items to a few hundred candidates, a ranker scores those candidates carefully, and a re-ranker reorders the top of the list for variety and business rules. Each stage spends its share of a latency budget, usually around 100 ms per request.
This case study designs a feed for 10 million users and 1 million items at 1,000 requests per second. Latency, compute and A/B test length are exact arithmetic. Recall, precision and diversity are measured on a seeded toy world of 300 users and 1,000 items whose true tastes are known, so every measurement can be checked against the answer key. The ranker's accuracy and the feedback loop are simulations, labelled as such on the page.
Key ideas
- A ranker that is affordable for a few hundred items is far too slow for a million, so feeds retrieve candidates first and rank only those.
- A two-tower model gives users and items vectors whose dot product predicts affinity, which turns retrieval into a nearest-neighbour search.
- Recall at retrieval caps everything after it: an item that is not retrieved cannot be ranked or shown.
- Ranker cost per item multiplies by the candidate count, so richer rankers and more candidates compete for the same latency budget.
- Maximal marginal relevance trades a little relevance for variety; category diversity does not by itself reach less popular items.
- A feed only collects clicks on what it shows, so without exploration the logs, and the next model, narrow to a small part of the catalog.
- Offline metrics choose which designs to test; an A/B test sized for the smallest effect worth detecting decides which design ships.
Common questions
Why do recommendation systems use two stages, retrieval and ranking?
Scoring every item with a rich model costs catalog size × cost per item: 1 million items at 0.1 ms each is 100 seconds per request. Retrieval uses a cheap model whose scores can be searched with an index, so it returns a few hundred candidates in milliseconds. The rich ranker then spends its budget only on those. YouTube's 2016 system described this split, with candidate generation feeding a separate ranking network.
What is a two-tower model?
Two neural networks, one for users and one for items, each map their input to a vector of the same size. The predicted affinity is the dot product of the two vectors. Item vectors can be computed ahead of time and stored in a vector index, so at request time only the user vector is computed and the index returns the items with the largest dot products.
How long should a recommendation A/B test run?
Long enough to reach the sample size for the smallest effect worth detecting. With a 5% baseline click rate, a 2% relative lift, α = 0.05 and 80% power, each arm needs about 753,000 users. At 300,000 test users a day that is 6 days. In practice it is common to run whole weeks, so weekday and weekend behaviour are both included.
Why do recommendation feeds keep showing popular items?
Clicks only come from items the feed shows, and the model learns only from those clicks. Items shown early collect evidence and keep their place, while items never shown keep whatever estimate they started with. In this case study's simulation, a feed with no exploration ever shows under 10% of the catalog. Giving a small share of slots to exploration costs some click-through rate and widens what the next model can learn from.
Related explainers
- Embeddings — Turning words and categories into vectors
- Vector Search & HNSW — Finding nearest embeddings fast with HNSW
- K-Nearest Neighbors — Classification by proximity and distance metrics
- Gradient Boosting — Sequential residual fitting for powerful predictions
- Model Evaluation & Metrics — Precision, recall, F1, ROC curves, and regression metrics
- Class Imbalance & Resampling — SMOTE, class weights, and metrics beyond accuracy
- Hypothesis Testing — Make principled decisions from data using null hypotheses, p-values, and significance levels
References
- Covington, Adams, and Sargin (2016), "Deep Neural Networks for YouTube Recommendations", RecSys
- Yi et al. (2019), "Sampling-Bias-Corrected Neural Modeling for Large Corpus Item Recommendations", RecSys
- Carbonell and Goldstein (1998), "The Use of MMR, Diversity-Based Reranking for Reordering Documents and Producing Summaries", SIGIR
- Chen et al. (2019), "Top-K Off-Policy Correction for a REINFORCE Recommender System", WSDM
- Kohavi, Longbotham, Sommerfield, and Henne (2009), "Controlled Experiments on the Web: Survey and Practical Guide", Data Mining and Knowledge Discovery
Last updated