arXiv:2608.22137cs.AI2026-08

让大模型在超长记忆中精准检索,同时控制生成上下文大小。

MegaMem: A Retrieval Solution for Ultra-Large Context Windows

论文配图:MegaMem: A Retrieval Solution for Ultra-Large Context Windows
图 1 · 摘自论文原文
  • 分离语义搜索与生成证据,用双视角检索提升效率。
  • 在50万份企业文档上实现82.26的综合得分和86.50的正确率。
  • 适合需要持久记忆的大规模企业级AI应用。

现代语言模型和智能体日益需要持久记忆来处理完整的代码库、长交互历史和异构企业记录。核心挑战是在保持数亿个标记可搜索的同时,仅向回答模型传递有限的源证据。我们提出MegaMem,一种源解析的双视图检索系统,将语义访问与生成证据分离。通过原始查询和转换查询分别搜索压缩记录与详细证据;每个压缩命中在互排名融合、去重和交叉编码器重排序前映射为不可变源ID;最终仅在固定预算内选取最高排名的详细证据用于生成。答案生成后,通过后置归属识别哪些加载源支持该答案。我们在包含超过50万份异构企业文档及约6.5亿令牌的EnterpriseRAG-Bench上评估MegaMem,整体得分从68.22提升至82.26,正确率达86.50。结果表明,MegaMem可在保持强答案准确性的前提下支持超大规模持久记忆。通过将可搜索记忆规模与生成上下文大小解耦,MegaMem为覆盖数亿至十亿令牌的记忆检索提供了可行路径。代码已开源:https://github.com/xfab-xinyuansong/MegaMem.git。

原文摘要 · Abstract (English)

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.

检索系统大模型企业应用持久记忆

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。