Scaling the Instagram Explore recommendations system

Vladislav Vorotilov, Ilnur Shugaepov9 Aug 2023

Problem

A feed serving hundreds of millions of people a day has billions of candidate items. Scoring every item with a heavy model is impossible within real-time latency. Heuristics adapt poorly, so the team prefers learned models wherever possible. The team also needs one ordering that balances several engagement signals, and hundreds of parameters to tune.

Example from the article: Instagram Explore picks items from billions of media for hundreds of millions of daily visitors and has to answer in real time.

Solution in brief

Split ranking into four stages: retrieval, a light first-stage ranker, a heavy second-stage ranker and a rule-based reranker. Caching and pre-computation at each stage let heavier, learned models replace heuristics. A value model sums predicted engagement probabilities with tunable weights, and the parameters are tuned by Bayesian optimization, online or offline.

Questions this case answers
  • How to rank a billion-item catalog for each user within a tight latency budget when a heavy model cannot score every candidate
  • How to combine several predicted engagement probabilities into one ranking score and tune its weights against competing online metrics
  • How to recommend the most relevant items out of billions in real time with a multi-stage funnel?
  • How to make a ranking stage cheap enough to score thousands of candidates per request?

Tools and methods

  • Two-tower model — user and item networks producing cacheable embeddings, used for retrieval and first-stage ranking
  • Approximate nearest neighbors (FAISS, HNSW) — online search of item embeddings close to the user embedding
  • Knowledge distillation — the first-stage ranker learns to predict the second stage's top-K selection
  • Multi-task multi-label (MTML) network — second-stage prediction of click, like, see less and other events
  • Value model — weighted sum of predicted probabilities giving the final score
  • Bayesian optimization — online or offline tuning of weights and funnel sizes
Continue reading — it's free

Google or a one-time email code. No password.