Introduction

By Ludovico Bessi, Senior ML Engineer at Google · Updated

A recommendation system predicts which items — videos, products, posts, ads — a user is most likely to value, and ranks them without the user asking. At scale it must choose from millions or billions of items for hundreds of millions of users in about 100–200 ms. This book explains how production recommenders at YouTube, Meta, TikTok, Pinterest and others are built.

Recommendations Run the Internet

Most of what people see online is chosen by a recommender: the YouTube home feed and "up next" list, TikTok's For You page, Netflix rows, Amazon's "customers also bought", LinkedIn's feed, Spotify's Discover Weekly, the ads between posts. Search answers an explicit question. A recommender answers an implicit one: of everything we could show this person right now, what is most worth their time?

At large platforms these systems drive a large share of engagement and revenue, which is why they get some of the largest ML teams and some of the largest models in production.

Why It Is Hard

A recommender has to pick a handful of items from a catalog of millions or billions, for hundreds of millions of users, within a latency budget of tens to a few hundred milliseconds, while the catalog, the users and their tastes change continuously. Each part of that sentence creates its own engineering problem:

  • Scale of the catalog. You cannot score a billion items per request with a large model. You need a funnel that narrows the catalog in stages (see The Multi-Stage Funnel Architecture).
  • Scale of users and traffic. Hundreds of thousands of requests per second means every millisecond and every byte of feature data per request costs real money.
  • Sparse, implicit feedback. Users rarely rate things. You learn from clicks, watches, skips and dwell time — noisy, biased signals of what people actually value.
  • Moving targets. New items arrive every second; a video's relevance can peak within hours. Models must be fresh.
  • Feedback loops. The system only observes reactions to what it chose to show. Its own past decisions shape its future training data (see Feedback Loops).
  • Many objectives. Clicks, watch time, satisfaction, creator health, diversity, revenue and safety all matter and often conflict (see Multi-Objective Optimization).

A Short History

  • Collaborative filtering (1990s–2000s). "People who liked X also liked Y." Item-to-item collaborative filtering powered Amazon's recommendations; matrix factorization won the Netflix Prize era by learning user and item vectors whose dot product predicts preference.
  • Feature-rich ranking (2010s). Gradient-boosted trees and logistic regression over hand-crafted features, then deep models: Wide & Deep (Google, 2016), YouTube's deep neural network recommender (2016), DeepFM, DCN, and Facebook's DLRM (2019). Embedding tables for sparse IDs became the defining component.
  • Sequence modeling (late 2010s). Treating a user's history as a sequence: attention over behavior (Alibaba's DIN), transformers over sessions (SASRec, BERT4Rec), long-history retrieval (SIM).
  • Generative and foundation models (2020s). Recommendation framed as sequence generation (Meta's HSTU, generative retrieval with semantic IDs), LLM-based recommenders, and single large models shared across many surfaces. Scaling laws, once a language-model topic, now drive recommender design too.

The Anatomy of a Modern System

Request (user, context)
   │
   ├─ Candidate generation   millions → thousands   (two-tower, ANN, graphs, rules)
   ├─ Pre-ranking            thousands → hundreds   (light model)
   ├─ Ranking                hundreds → dozens      (deep multi-task model)
   └─ Re-ranking             dozens → final list    (diversity, business rules, policy)
   │
Logged impressions and feedback → training data → models (the flywheel)

Around this sit a feature platform (user history, item metadata, real-time counters), training pipelines that run continuously, experimentation infrastructure for A/B tests, and monitoring.

How This Book Is Organized

Key Takeaways

  1. A recommender chooses a few items from millions under tight latency, learning from implicit, biased feedback.
  2. The field moved from collaborative filtering to deep feature-rich ranking, then to sequence models and now generative and foundation models.
  3. Production systems are funnels: cheap, high-recall retrieval followed by increasingly expensive ranking.
  4. The system's own decisions create its training data, so feedback loops and bias are first-class concerns.