Abstract
MemoRAG is a novel Retrieval-Augmented Generation (RAG) framework that mimics human cognition by building a "global memory" of long documents to guide information retrieval. By utilizing a dual-system architecture—comprising a lightweight model for memory formation and a more expressive model for generation—MemoRAG addresses the limitations of standard RAG and long-context Large Language Models (LLMs). It significantly outperforms existing methods on complex tasks like summarization and multi-hop reasoning, achieving superior accuracy and efficiency in processing contexts up to one million tokens.
Introduction: The Challenge of Long Contexts
Large Language Models (LLMs) have evolved to handle increasingly long contexts, often reaching 128K tokens or more. However, processing such massive inputs directly is computationally prohibitive and slow. Retrieval-Augmented Generation (RAG) has emerged as a standard alternative, yet it faces two critical hurdles: the requirement for explicit, specific queries and a dependency on structured, chunkable knowledge. Traditional RAG struggles with high-level, "unsearchable" queries—such as "Summarize the main themes of this book"—because the necessary evidence is distributed across the text rather than contained in a single chunk. This "semantic gap" often leads to retrieval failure.
The MemoRAG Framework: A Dual-System Architecture
MemoRAG introduces a dual-system architecture inspired by human memory processes. Unlike standard RAG, which searches blindly, MemoRAG "remembers" the gist first to guide the retrieval of supporting details.
- System 1: The Memory Module (Lightweight): This system skims the entire long context to form a "global memory." It employs KV Compression, condensing the context into a smaller set of "memory tokens" to handle up to 1 million tokens efficiently. When presented with a query, this module generates "clues" or draft answers that act as semantic bridges for the retriever.
- System 2: The Generator (Expressive): A more powerful LLM that synthesizes the final response using the retrieved evidence and the original query.
Training and Optimization
The memory module is optimized through Supervised Fine-Tuning (SFT) and a novel Reinforcement Learning with Generation Feedback (RLGF) approach. In RLGF, the memory module is rewarded when its generated clues lead to a correct final answer from the generator, ensuring the memory formation is task-aligned.
Datasets and Evaluation
The researchers evaluated MemoRAG on several benchmarks, including LongBench and InfiniteBench for standard long-context tasks. Additionally, they introduced UltraDomain, a benchmark consisting of 20 datasets across diverse fields such as law, finance, and physics. UltraDomain features contexts up to 1 million tokens and requires high-level reasoning that traditional RAG typically fails to handle.
Key Insights: "Remember then Locate"
The core innovation of MemoRAG is the "Remember then Locate" paradigm. By generating draft answers from memory, the system effectively rewrites the user's intent into a form that is much easier for a standard retriever (like BGE-M3) to find in the raw text. This allows it to handle "unsearchable" queries by recalling key points from memory to guide the retrieval of supporting details.
Results and Performance
MemoRAG achieved an average score of 40.2 across benchmarks, outperforming "Full Context" LLM processing (35.0) and advanced RAG methods like GraphRAG (29.4) and HyDE. It showed the most significant gains in "Complex Tasks" and "Summarization," where traditional RAG methods often fall apart. While indexing is slower than basic RAG due to the memory formation step, it is much faster than the pre-filling stage of long-context LLMs and significantly more efficient than GraphRAG.
Limitations and Future Work
While higher compression ratios save memory, they can lead to a slight decline in performance as semantic richness is lost. Furthermore, forming the global memory is more time-consuming than simple vector indexing. Future work will explore more heterogeneous model pairings and further optimize KV compression algorithms to retain more detail at high compression rates.
Summary updated