Meta 长记忆搜索建模:如何扩展广告推荐的历史上下文
Meta Long Memory Search Modeling: How Meta Is Scaling Extended History Context for Ads Recommendation Modeling
Meta 长记忆搜索建模通过将用户长时间的互动历史纳入广告推荐系统,提高了点击率和转化率,提升了广告效果。该模型采用检索增强生成(RAG)技术,通过查询、索引、检索和增强四个步骤,从用户历史中检索相关信号,实现高效的历史上下文扩展,同时保持多样性。相比仅保留最近历史的 LastN 方法,该模型在计算效率上提高了 5-10 倍。
- Meta Long Memory Search Modeling is Meta’s machine learning (ML) technology that leverages longer user engagement history to improve ads recommendations and deliver value to people and our advertisers.
- This modeling approach adapts retrieval-augmented generation (RAG) techniques from large language models (LLMs) for use in ads recommendations.
- By treating engagement history as an indexed set of documents, a small subset of relevant context can be selected to ensure ads recommendations take long-term preferences into account.
- Meta Long Memory Search Modeling has enabled long history and delivered a 1% lift in click-through rate on Facebook Feed and Reels and 1.2% lift in conversion rate, while being 5-10x more efficient on compute than linear history scaling.
Meta continues to scale the AI behind its ads recommendation system, from sequence learning to foundation models such as GEM trained at LLM scale. This model scaling helps people discover businesses they care about and advertisers reach the right customers.
Although larger models can learn more complex relationships between people and ads, they’re limited by how much data history they can use. Long-term patterns, such as seasonal shopping habits and evolving interests, carry signals that short history windows miss. The default approach to history, LastN, keeps only the last N events or days for use in ads recommendations. LastN is simple and filters noise, but it discards relevant history and applies the same cutoff to every person.
Scaling history beyond LastN poses three interrelated challenges:
- Identifying the most relevant interactions: An entire history of events is generally not relevant for improving model quality and advertiser performance. We need to identify the subset of history that maximizes advertiser performance and ensure it is not diluted by everything else.
- Resource constraints and system efficiency: The cost of storing, serving, and processing full histories grows linearly to quadratically with their length, which real-time ranking cannot afford.
- Catastrophic forgetting: Models trained on rolling windows of recent data gradually overwrite older patterns. This can result in models forgetting important context from older events.
Meta Long Memory Search Modeling is Meta’s approach to treating history scaling as a retrieval problem. Similar to retrieval-augmented generation (RAG) for LLMs, it treats engagement history as a document corpus and each ad request as a query, then retrieves a subset of relevant and diverse past signals. This allows Meta’s ads recommendation systems to leverage important long-history context while staying within tight constraints, resulting in better ads for people on our platforms and stronger value to our advertisers.
The Solution: Meta Long Memory Search Modeling

Design Approach
Meta Long Memory Search Modeling adapts the four parts of a RAG pipeline (query, index, retrieval, and augmentation) to extended user history. In RAG for LLMs, someone’s question is the query, a text corpus is the document store, a retriever selects relevant passages, and those passages are added to the model’s context. Meta Long Memory Search Modeling mirrors each step:
- Query: Each ad request generates a query that encodes signals such as recency, user cohort, ad category, and interest topics. A query can emphasize topical relevance (“history related to this ad category”) or recency (“the most recent engagement pattern”).
- Index: A person’s eligible engagement history is organized into retrievable units across time and topic, similar to document chunks in text-based RAG. Each unit summarizes engagement from one data source over a defined time period.
- Retrieval: A retrieval model scores index entries against the query and turns sparse, noisy event data into a compact set of relevant, non-redundant signals.
- Augmentation: The retrieved entries become additional context for the ranking model, as embeddings, training examples, or events for user sequence models and GEM.
Meta Long Memory Search — Model

Retrieval quality depends on more than finding the strongest matches. Recent behavior tends to repeat itself, so the closest matches to a request are often near-copies of the same recent interest. These matches are highly relevant but add little new information, and they can also crowd out older signals that motivated including a longer history in the first place.
To balance relevance with diversity, Meta Long Memory Search Modeling uses Maximal Marginal Relevance (MMR). Each candidate is scored on how well it fits the current decision, measured against both the person’s current interests and the ad being ranked, and how different it is from what has already been selected. A candidate that closely duplicates something already in the set is penalized, even if it’s relevant on its own.
Balancing relevance with diversity lets us cover more history. A recent interest, a recurring one, and a longer consideration cycle can all be represented, rather than one interest repeated many times. For advertisers, this results in broader coverage of intent because our systems draw on the different reasons a person might be interested in an ad, not just the most recent one.
Meta Long Memory Search — Infrastructure
Meta’s ads systems rank a large number of candidate ads for every request within a tight latency budget. All data preprocessing, including Long Memory search and summarization, has to fit inside this budget while being efficient enough to extend across ranking models rather than serve a single model.
A few design choices allow Meta Long Memory Search Modeling to function within these constraints:
- Time-based chunking: Consecutive days of history are grouped into coarser weekly units, reducing how much must be stored and searched while leveraging the information that matters.
- Compact representations: Learned representations are quantized into compact numeric formats, reducing the memory and bandwidth needed to store and move them.
- Nearest-neighbor search over a vector index: History is indexed in a vector database, so retrieval finds strong matches quickly instead of scanning a person’s full history for every request.
- Asynchronous preparation: Indexing and other preparations occur before a request arrives, keeping that work off the latency-critical path.
Each of these is a separate lever — for index cost, storage and transport, or latency — and together have kept Meta Long Memory Search Modeling retrieval with minimal overhead.
Applications
Meta Long Memory Search Modeling has multiple applications that share a common pipeline but target different stages of ads ranking. At inference time, we can retrieve historical embeddings that ranking models use as added features. At training time, we can retrieve older training examples and replay them in a second training pass to counter forgetting.


For embeddings, a recurring interest can inform a relevant ranking decision months later, while the decision remains grounded in the current request. For advertisers, this helps ad opportunities align with consideration cycles that don’t fit a recent window. For training data, ranking models can leverage useful older patterns instead of forgetting them, and learn when longer-horizon signals should matter. And they do it without reprocessing the entire user history.

The embeddings and training data applications reinforce each other. Training data teaches models when longer-horizon signals are useful, and online retrieval then makes those signals available within a ranking request. Because both applications share infrastructure, improvements made for one can benefit the other.
Impact and Future Work
Meta Long Memory Search Modeling has been deployed into production for major ads ranking models since 2025. In production, selective long-horizon learning delivered a 1% click-through rate lift for ads on Facebook Feed and Reels. Compared with linear history scaling, Meta Long Memory Search Modeling achieves better NE in CTR and CVR models, and combined with system improvements, delivers 5-10x better modeling ROI while adding minimal end-to-end serving overhead.

For the RecSys community, this work illustrates another axis for scaling recommendation quality, as we demonstrate that larger models and longer raw sequences aren’t the only options. Our work enables data scaling to be achieved while being selective about long-history context.
Looking ahead, we’ll advance Meta Long Memory Search Modeling on multiple fronts. Beyond embedding and training data applications, we’ll bring long history directly into user sequence models. To perform this, we can condense long histories into fixed-length sequences at both raw-event and learned latent-representations levels, which will help user sequence models leverage both fine-grained details and broad patterns. We’ll also improve the model-infrastructure co-design, scale to even longer histories, and capture seasonal patterns that recur year over year. This future work will further improve our systems to deliver the best ads for people on our platforms and strong value to our advertisers.
Acknowledgments
We would like to thank Nafis Abrar, Shuo Chen, Victor Chen, Xian Chen, Jieming Di, Suofei Feng, Bin Gao, Edison Gao, Tina Jiang, Atul Katiyar, Santanu Kolay, Can Koyuncu, Lilly Kumari, Ling Leng, Chao Li, Kungang Li, Shiyi Li, Ericka Liu, Xiaoran Liu, Yu Lu, Anuj Madan, Zubair Mughal, Sean O’Byrne, Sandeep Pandey, Duo Qu, Aakanksha Ronald Sanctis, Ketan Singh, Shivendra Pratap Singh, Matt Steiner, Dorothy Sun, Viral Vimawala, Tianshi Wang, Shuxing Xiao, Junwei Xiong, Yiwen Xu, Tak Yan, Qiao Yang, Kevin Yin, Abdul Zainul-Abedin, Yuan Zhang, Carolina Zheng, Yangxin Zhong, and Wankun Zhu for their help in making Meta Long Memory Search Modeling successful.
The post Meta Long Memory Search Modeling: How Meta Is Scaling Extended History Context for Ads Recommendation Modeling appeared first on Engineering at Meta.
来源: Meta Engineering · engineering.fb.com