MegaMem: A Retrieval Solution for Ultra-Large Context Windows

arXiv:2608.22137 · cs.AI · Submitted 2026-08-22 · Read on arXiv

Listen

Radio episode about this paper

Transcript

Introduction to the show: ident: AI Radio. Generated commentary on the latest Artificial Intelligence papers.

Tom: Today's paper: "MegaMem: A Retrieval Solution for Ultra-Large Context Windows".

Jane: The gist MegaMem introduces a source-resolved dual-view retrieval system that separates semantic access from generation evidence to support ultra-large persistent memory while keeping the generation context bounded.

Tom: First, who's behind it and why it matters.

Title and authors: Tom: So we're looking at this paper, 'MegaMem: A Retrieval Solution for Ultra-Large Context Windows'. The title itself tells you exactly what it's trying to tackle, which is scaling up retrieval systems that have massive amounts of data. It’s not just about fitting bigger models; it’s about managing how we search through those huge stores effectively.

Jane: Right, and the authors are Xinyuan Song, Bowen Zhu, Hasibul Haque, Liang Zhao at Emory University and the Causal Dynamics Lab at Emory University. They've got a solid team behind this work.

Tom: What they are doing is introducing a source-resolved dual-view retrieval system. That sounds complicated, but the core idea is that you separate what you can search—the persistent context—from what you actually use to generate an answer, which is the evidence context.

Lu: Exactly, Tom. The paper suggests that instead of just searching through everything and throwing a lot of noise at the model to get an answer, we need a way to keep the search broad while keeping the final input small and focused on what’s actually relevant to the question.

Meng: I wonder how much extra storage this system needs for all these dual views. If we're talking about hundreds of millions or even a billion tokens, storing both detailed evidence and those distilled memories sounds like it could be quite demanding on resources.

Lalam: From my perspective, if the system can keep the search space vast without overwhelming the generation context, that’s what matters most for deploying these things in production environments.

The paper's summary: Tom: So, to summarize what MegaMem proposes here is this source-resolved dual-view retrieval system. It takes the massive persistent context and breaks it down into two different types of memory structures.

Jane: Think of it like this: you have the original documents with all their detailed evidence, and then you create these more compact, typed memories for each piece of that evidence.

Lu: That’s right. Then you index both views separately: one detailed index for the raw chunks and another distilled index for those compact memories. This lets them search in two different ways simultaneously.

Tom: The retrieval part is where it gets interesting because they build multiple query routes, including a canonical rewrite and some terminology diverse expansions, searching both of those indices at the same time.

Meng: Searching multiple routes sounds computationally expensive. How do you manage the complexity when you're trying to keep things fast for online retrieval?

Jane: They solve that by resolving all those distilled hits back to their original detailed chunks before they even start aggregating candidates, which keeps things grounded in reality.

Lalam: And then they use weighted reciprocal rank fusion and a cross-encoder reranking step to combine the results from all those routes into one final ranked list.

The paper's improvements: Tom: The main improvement they highlight is this separation of semantic access from generation evidence. That’s the big idea that lets them scale the searchable context up significantly while keeping the evidence context bounded.

Jane: They show that this approach is effective even when scaling persistent memory up to two hundred fifty million tokens under a fixed budget for what they consider the evidence budget.

Lu: The analysis shows that performance doesn't just drop off sharply as you go from, say, twenty million tokens to two hundred fifty million tokens. It degrades gradually instead of collapsing. That’s a key finding about how robust this architecture is when scaling up the context size.

Meng: From an engineering standpoint, that gradual degradation is better than a total failure when we’re trying to keep things running reliably at scale. What about the cost of building this dual index structure initially?

Tom: They estimate the offline construction cost for two hundred fifty million tokens to be about five point six days, which is manageable for an initial setup, but they emphasize that this is done once before you start querying.

Jane: And they also have a post-answer attribution step. This identifies which of those loaded sources actually supported the final answer and reduces the reported source set without changing the quality of the answer itself.

Conclusion: Tom: So, wrapping this up for MegaMem: it successfully addresses that problem we talked about—scaling persistent memory while keeping the evidence context bounded. It shows a practical path toward handling memories ranging from hundreds of millions to one billion tokens accurately.

Jane: The architecture design study found that combining those distilled retrieval keys with the source-resolved detailed evidence is more effective than just retrieving directly from the original corpus. It’s about that careful selection process they built in.

Lu: I think what’s really important is how they separated the roles: query transformation broadens recall, reranking selects the specific evidence used for generation, and post-answer attribution cleans up the final source set. That separation is the key architectural change here.

Meng: For deployment, it seems like online retrieval stays under one point one second at one hundred million tokens, and end-to-end answering stays under three point three seconds. Those are achievable numbers we need to see when we build production systems.

Lalam: I agree with the performance metrics. They achieve an overall score of eighty-two point three in their architecture design study, which shows that this dual-view approach is the most effective way to combine compressed retrieval keys with source-resolved detailed evidence for large context windows <ref:2608.22137#pg1>.

Emory University

cs.AI

Submitted: 2026-08-22

Updated: 2026-10-15

Code: https://github.com/xfab-xinyuansong/MegaMem

License: http://creativecommons.org/licenses/by/4.0/

Importance score: 89/100

The gist: The gist MegaMem introduces a source-resolved dual-view retrieval system that separates semantic access from generation evidence to support ultra-large persistent memory while keeping the generation

Key concepts

Dual-View Memory Construction
This involves segmenting large documents into detailed evidence pieces and creating up to three compact, typed memories for each piece. These pieces are then indexed in two separate ways: one index holds embeddings of the original detailed chunks, and another stores embeddings of the distilled summaries.
Distilled Index
The distilled index stores embeddings derived from compact, typed memories rather than the full source text. This allows for faster searching across a much larger set of information while maintaining semantic relevance to the original content. These summaries are used as a proxy for the detailed evidence during retrieval.
Source-Resolved Retrieval
Every retrieved hit from the distilled index is mapped back to its specific, immutable source ID in the detailed index before any final ranking occurs. This ensures that when evidence is selected for answering, it can be precisely traced back to its original location in the massive corpus.
Bounded-Evidence Generation
The system uses a fixed budget of detailed evidence chunks to support answer generation, even if the initial search returned many candidates. After selecting the highest-ranked detailed evidence within this budget, post-answer attribution identifies exactly which loaded sources provided that final answer.

Summary

The gist MegaMem introduces a source-resolved dual-view retrieval system that separates semantic access from generation evidence to support ultra-large persistent memory while keeping the generation context bounded.

Problem Formulation

Persistent memory systems must scale searchable corpora while maintaining a bounded evidence context for answer generation, which is challenging because retrieving more content increases distractors and degrades performance. The goal is to scale the former without increasing the latter at the same rate.

Method

MegaMem operates in three stages: dual-view memory construction, multi-route retrieval, and bounded-evidence generation with postanswer attribution.

  1. Dual-View Memory Construction involves segmenting documents into detailed evidence chunks and extracting up to three compact typed memories for each chunk.

  2. The resulting corpus is indexed in two complementary views: a detailed index storing embeddings of original evidence chunks and a distilled index storing embeddings of the typed memories.

  3. Multi-Route Retrieval involves constructing multiple query routes, including a canonical rewrite and terminologydiverse expansions, searching both indices.

  4. All distilled hits are resolved to their corresponding detailed chunks before candidate aggregation.

  5. Rankings from different routes are combined using weighted reciprocal rank fusion (SRRF) and then reranked using a cross-encoder.

  6. The answer is generated under an evidence-only instruction: a = A q, E(q)

Results and Analysis

MegaMem was evaluated on EnterpriseRAGBench, where it improved Overall from 68.22 to 82.26 and reached 86.50 Correctness. The strongest gains come from dual-view retrieval and distillation.

Scaling tests showed that MegaMem remains effective as persistent memory grows up to 250M tokens under a fixed evidence budget. Performance degrades gradually rather than collapsing from 20M to 250M tokens.

Component analysis showed that the dual index and distillation provide the largest gains. Post-answer attribution further improves source reporting, reducing InvDocs from 0.774 to 0.760 without changing answer quality.

Efficiency and Trade-offs

MegaMem provides a favorable accuracy–context trade-off: it reduces answer-model input by more than two-thirds while preserving nearly all of the Correctness obtained with full detailed evidence. The offline construction cost for 250M tokens is approximately 5.6 days.

Conclusion

MegaMem successfully addresses the problem of ultra-large persistent memory by separating searchable context from bounded evidence context, demonstrating a practical path toward accurate retrieval over memories ranging from hundreds of millions to one billion tokens.

The system's design separates three roles in the pipeline: Query transformation broadens candidate recall, reranking selects the evidence used for generation, and post-answer attribution reduces the final source set. The architecture design study confirms that the transition from compressed-only memory to source-resolved dual-view retrieval is the key architectural change.

The system's operational efficiency shows that online retrieval remains below 1.1 seconds at 100M tokens, and end-toend answering remains below 3.3 seconds. The final system achieves the best overall performance while keeping the generation context bounded as persistent memory grows. The limitations noted include that source precision remains lower than the published EnterpriseRAGBench leader and performance on LoCoMo and UltraDomain shows that the current document-oriented retrieval design does not transfer uniformly to conversational or broad cross-domain memory stores. The model does not extend the native attention window of the underlying language model.

The final system achieves an overall score of 82.3 in the architecture design study. The results show that combining distilled retrieval keys with source-resolved detailed evidence is more effective than directly retrieving only from the original corpus.

The system's design separates persistent memory, retrieval candidates, loaded evidence, and reported sources <ref:2608.

Improvements for AI systems

  1. Bold retrieval mechanism for ultra-large memory: MegaMem separates semantic access from generation evidence, allowing systems to search hundreds of millions to one billion tokens while only passing a bounded source evidence to the answer model.

  2. Source-resolved dual-view retrieval: The system uses a dual index where every distilled hit is resolved to an immutable source ID before fusion, ensuring that only detailed source evidence enters generation, thus preserving source-faithful generation.

  3. Post-answer attribution for precision: A separate module identifies which loaded sources support the fixed answer, which reduces the reported source set without changing answer quality and confirms that retrieval and reranking determine the evidence shown to the answer model.

  4. Memory scaling capability: The system can scale persistent memory from 20M to 250M tokens while keeping the evidence budget fixed, demonstrating that ultra-large persistent memory can be made addressable while keeping the evidence context bounded.

  5. Query transformation for recall: Using query expansion and terminology-diverse alternatives broadens retrieval and recovers missed targets, with query expansion showing gains of 20.8–100.0% across answerable categories.

Abstract

Modern language models and agents increasingly require persistent memory for complete codebases, long interaction histories, and heterogeneous enterprise records. The key challenge is to keep hundreds of millions of tokens searchable while passing only bounded source evidence to the answer model. We introduce MegaMem, a source-resolved dual-view retrieval system that separates semantic access from generation evidence. Distilled records and detailed evidence are searched with original and transformed queries; every distilled hit resolves to an immutable source ID before reciprocal-rank fusion, deduplication, and cross-encoder reranking; and only the highest-ranked detailed evidence within a fixed budget supports generation. Post-answer attribution then identifies which loaded sources support the fixed answer. We evaluate MegaMem on EnterpriseRAG-Bench, which contains more than 500,000 heterogeneous enterprise documents and approximately 650M tokens. MegaMem improves Overall from 68.22 to 82.26 and reaches 86.50 Correctness. These results show that MegaMem supports ultra-large persistent memory while preserving strong answer accuracy under a bounded generation context. By separating searchable memory scale from answer-context size, MegaMem provides a practical path toward accurate retrieval over memories ranging from hundreds of millions to one billion tokens. Our code is available at https://github.com/ xfab-xinyuansong/MegaMem.git.

Sources

Related papers