arXiv:2409.05591cs.CLcs.AI2024-09被引 148

用全局记忆增强检索,让大模型更高效处理长文本。

MemoRAG: Boosting Long Context Processing with Global Memory-Enhanced Retrieval Augmentation

  • 构建双系统架构,用轻量长程记忆捕捉上下文全局信息
  • 在32K以上上下文任务中表现超越传统RAG方法
  • 适合需要理解超长文档的场景,如法律、科研分析

长上下文处理是大语言模型面临的核心挑战。尽管现有技术已支持32K甚至128K令牌的上下文,但计算成本高且仍不足够。检索增强生成(RAG)被视为有效解决方案,但传统RAG依赖显式查询和结构化知识,在实际长文本任务中难以满足。本文提出MemoRAG,一种基于全局记忆增强检索的新框架。该框架采用双系统设计:首先通过轻量级长程系统构建上下文全局记忆;当任务出现时,生成草稿答案,为检索工具提供关键线索以定位相关信息;随后利用计算昂贵但表达能力强的系统,基于检索内容生成最终答案。我们实现记忆模块为键值压缩形式,并引入生成质量反馈(RLGF)强化其记忆与提示能力。实验表明,MemoRAG在多种长上下文评估任务中表现优异,不仅在传统RAG难以应对的复杂场景中胜出,也在常规应用场景中优于现有方法。

原文摘要 · Abstract (English)

Processing long contexts presents a significant challenge for large language models (LLMs). While recent advancements allow LLMs to handle much longer contexts than before (e.g., 32K or 128K tokens), it is computationally expensive and can still be insufficient for many applications. Retrieval-Augmented Generation (RAG) is considered a promising strategy to address this problem. However, conventional RAG methods face inherent limitations because of two underlying requirements: 1) explicitly stated queries, and 2) well-structured knowledge. These conditions, however, do not hold in general long-context processing tasks. In this work, we propose MemoRAG, a novel RAG framework empowered by global memory-augmented retrieval. MemoRAG features a dual-system architecture. First, it employs a light but long-range system to create a global memory of the long context. Once a task is presented, it generates draft answers, providing useful clues for the retrieval tools to locate relevant information within the long context. Second, it leverages an expensive but expressive system, which generates the final answer based on the retrieved information. Building upon this fundamental framework, we realize the memory module in the form of KV compression, and reinforce its memorization and cluing capacity from the Generation quality's Feedback (a.k.a. RLGF). In our experiments, MemoRAG achieves superior performances across a variety of long-context evaluation tasks, not only complex scenarios where traditional RAG methods struggle, but also simpler ones where RAG is typically applied.

长上下文检索增强记忆机制大模型

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