Retrieval-Augmented Generation (RAG) has become an essential method for mitigating hallucinations in Large Language Models (LLMs) by leveraging external knowledge. Although effective for simple queries, traditional RAG struggles with large-scale, unstructured corpora where information is highly fragmented. Graph-based RAG (GraphRAG) incorporates knowledge graphs to capture structural relationships, enabling more comprehensive retrieval for complex reasoning. However, existing GraphRAG methods rely on isolated, fragment-level extraction for graph construction, lacking a global perspective on the whole corpus. As a result, these methods frequently lead to thematically inconsistent, logically conflicting, and structurally fragmented graphs that degrade retrieval performance. In this paper, we propose MemGraphRAG, a novel framework that introduces a memory-based multi-agent system to ensure high-quality graph construction. Specifically, MemGraphRAG employs a collaborative society of agents supported by shared memory, which provides a unified global context throughout the extraction process. This mechanism allows agents to dynamically resolve logical conflicts and maintain structural connectivity throughout the corpus. Furthermore, we propose a memory-aware hierarchical retrieval algorithm tailored for the constructed graph. Extensive experiments on multiple benchmarks demonstrate that MemGraphRAG outperforms the state-of-the-art baseline models with comparable efficiency. Our code is available at https://github.com/XMUDeepLIT/MemGraphRAG.
翻译:检索增强生成(RAG)已成为通过利用外部知识减轻大语言模型(LLMs)幻觉的重要方法。尽管对简单查询有效,但传统RAG在处理信息高度碎片化的大规模非结构化语料库时存在困难。基于图的RAG(GraphRAG)通过引入知识图谱捕获结构关系,能够为复杂推理实现更全面的检索。然而,现有GraphRAG方法依赖孤立的片段级提取构建图,缺乏对整个语料库的全局视角。这导致这些方法经常产生主题不一致、逻辑冲突且结构碎片化的图,从而降低检索性能。本文提出MemGraphRAG,一种新颖框架,通过引入基于记忆的多智能体系统确保高质量的图构建。具体而言,MemGraphRAG采用由共享记忆支持的协作智能体群体,在提取过程中提供统一的全局上下文。该机制使智能体能够动态解决逻辑冲突并维持整个语料库的结构连通性。此外,我们提出一种针对所构建图定制的记忆感知分层检索算法。在多个基准测试上的广泛实验表明,MemGraphRAG以相当效率超越了最先进的基线模型。我们的代码可在https://github.com/XMUDeepLIT/MemGraphRAG获取。