Candidate Generation in the Wild
By Ludovico Bessi, Senior ML Engineer at Google · Updated
Candidate generation is the retrieval stage that picks a few thousand items from the full catalog for ranking. This chapter covers how YouTube, Pinterest, Alibaba, TikTok and Airbnb built theirs — extreme classification, graph random walks, multi-interest embeddings, tree indexes and real-time embedding updates — and the lessons they share.
Why Look at Real Systems
Published industry systems show which ideas survive contact with production. Each solved retrieval differently because their products differ: watch-next video, visual discovery, a short-video feed, e-commerce. This chapter walks through representative designs and the lessons they share.
YouTube: Retrieval as Extreme Classification
YouTube's 2016 paper ("Deep Neural Networks for YouTube Recommendations", Covington et al.) framed candidate generation as extreme multiclass classification: predict which video, out of millions, a user will watch next.
- Inputs: averaged embeddings of recently watched videos and search tokens, plus demographics and an "example age" feature.
- Training: sampled softmax over millions of classes, with positives from watches (including those outside recommendations, to avoid only learning what the system already showed).
- Serving: the last hidden layer is the user embedding; the softmax weights are the video embeddings; retrieval is nearest-neighbor search in that space.
- Notable details: predicting the next watch rather than a held-out random watch (avoiding future leakage), a fixed number of training examples per user so heavy users do not dominate, and the example-age feature to model freshness.
Later YouTube work added sampling-bias correction to two-tower retrieval (Yi et al., 2019) and multi-objective ranking. For a deeper walkthrough, see the YouTube paper explained.
Pinterest: Graphs and Content
Pinterest's catalog is images saved to boards by users, which forms a natural graph.
- Pixie: real-time random walks over a pin–board graph held in memory, starting from the user's recent pins. Fast, explainable, and strong for related-pin recommendations.
- PinSage: a graph convolutional network that produces pin embeddings from visual and text features plus neighborhood structure, trained at billion-node scale with random-walk-based neighborhood sampling.
- PinnerSage: represents each user with multiple embeddings by clustering their engaged pins, then retrieves for each cluster — a practical multi-interest approach.
Lesson: when your data is naturally a graph, graph walks and graph embeddings are strong retrieval sources, and multi-embedding users beat a single averaged vector.
Alibaba: Multi-Interest and Tree-Based Retrieval
E-commerce users have many simultaneous needs.
- MIND (Multi-Interest Network with Dynamic routing): extracts several interest vectors from behavior with capsule-style routing; each retrieves its own candidates.
- TDM (Tree-based Deep Model): organizes items into a hierarchy and uses beam search down the tree with a deep model scoring nodes, allowing models more expressive than a dot product during retrieval.
Lesson: when one user vector cannot represent a user, retrieve with several; when a dot product is too weak, structured search can allow richer scoring.
TikTok / ByteDance: Real-Time Everything
TikTok's feed is famous for how quickly it adapts. ByteDance's Monolith paper (2022) describes the infrastructure behind real-time recommendation training:
- Collisionless embedding tables (cuckoo hashing) so new IDs get their own embeddings instead of colliding in hashed buckets.
- Expirable embeddings and frequency filtering to control table growth: IDs seen rarely are not given embeddings, stale ones are evicted.
- Online training: models are trained continuously on streaming data and parameters are synced to serving frequently, so the system reacts to new interests and new videos within minutes.
Lesson: for fast-moving catalogs, freshness of the model can matter as much as its architecture. See TikTok's real-time recommendation system.
Airbnb: Embeddings from Sessions
Airbnb learned listing embeddings from search sessions with a skip-gram model (treating sequences of clicked listings like sentences), adding the eventually booked listing as global context and market-aware negatives. These embeddings power similar-listing recommendations and real-time personalization of search. Later work moved to two-tower embedding-based retrieval for search. See Airbnb's embedding retrieval.
Lesson: session co-occurrence is a cheap, strong signal for item similarity.
Generative Retrieval: Semantic IDs
A newer approach replaces the ANN index with generation. Google's TIGER (Rajput et al., 2023) assigns each item a semantic ID: a short sequence of discrete codes produced by quantizing its content embedding (with a residual-quantized VAE), so similar items share code prefixes. A sequence-to-sequence model then generates the semantic IDs of the next items directly from the user's history. Benefits include sharing knowledge between similar items (helping cold start) and not needing a separate ANN index. Kuaishou's OneRec pushes this further to an end-to-end generative recommender. See Sequential Generative Recommenders.
Common Lessons
- Retrieve with several methods. Every system above combines embeddings with other sources.
- Match the method to the data. Graphs for graph-shaped products, sessions for browsing, content for cold start.
- Represent multi-interest users with multiple vectors.
- Correct popularity bias in training; otherwise retrieval collapses onto popular items.
- Freshness wins in fast-moving catalogs; real-time training and index updates matter.
- Use the full engagement signal, not just recommended impressions, to avoid learning only what you already show.
Key Takeaways
- YouTube framed retrieval as extreme classification with sampled softmax over watches.
- Pinterest combined real-time graph walks with GCN embeddings and multi-embedding users.
- Alibaba's MIND and TDM addressed multi-interest users and richer retrieval scoring.
- ByteDance's Monolith shows how real-time training and collisionless embeddings keep a feed fresh.
- Semantic-ID generative retrieval is an emerging alternative to ANN indexes.