Menu
Meta Engineering·December 4, 2026

Scaling Extended History Context for Ads Recommendation Systems

Meta's engineering team details how they adapted Retrieval-Augmented Generation (RAG) principles to ads recommendation systems, overcoming the computational limits of linear history scaling through vector indexing, time-based chunking, and Maximal Marginal Relevance.

Read original on Meta Engineering

The Challenge of History Scaling in Recommendations

Traditional recommendation models typically rely on a short-term window of user interactions (LastN) to filter noise and maintain low inference latency. However, discarding long-term user history leads to catastrophic forgetting of seasonal preferences and evolving user interests. Scaling history linearly introduces severe bottlenecks in storage, compute, and real-time serving costs.

Applying RAG Principles to User Engagement History

To solve the scalability and relevance challenges, Meta adapted the four core components of a Retrieval-Augmented Generation pipeline to manage user history as a retrievable document store rather than a continuous sequence.

  • Query Generation: Ad requests encode signals like recency, user cohort, and ad categories to query the history store.
  • Time-Based Chunking & Indexing: Consecutive days of engagement are aggregated into weekly units and stored in a vector database.
  • Maximal Marginal Relevance (MMR): Balances relevance with diversity, ensuring retrieved items avoid redundancy while covering multiple intent cycles.

Infrastructure and Latency Optimization

Ranking systems must operate within strict millisecond latency budgets. Meta achieved minimal serving overhead through specific infrastructure choices, including asynchronous index preparation before requests arrive, quantization of learned representations into compact numeric formats, and nearest-neighbor search over a vector index.

ℹ️

Dual Application Architecture

The long-memory architecture serves both online inference (providing historical embeddings as ranking features) and offline training (replaying older training examples to counter catastrophic forgetting).

RAGrecommendation systemsvector databaselatency optimizationmachine learning infrastructureembeddings

Comments

Loading comments...

Want the fundamentals behind stories like this? Take the free System Design Academy course with certificate.