LEGO-GraphRAG: Modularizing Graph-based Retrieval-Augmented Generation for Design Space Exploration

Yukun Cao, Zengyi Gao, Zhiyang Li, Xike Xie, S. Kevin Zhou

TL;DR

This paper introduces LEGO-GraphRAG, a modular framework for analyzing and building Graph-based Retrieval-Augmented Generation (GraphRAG) systems. By breaking down GraphRAG into distinct modules and categorizing techniques, it enables systematic evaluation and the discovery of optimal configurations for balancing performance, efficiency, and cost.

What Problem Does This Paper Address?

Large Language Models (LLMs) are powerful but often struggle with domain-specific knowledge and can "hallucinate." Retrieval-Augmented Generation (RAG) addresses this by grounding LLMs with external knowledge. GraphRAG, a specific type of RAG, leverages knowledge graphs (KGs) to provide more structured and relevant information. However, existing GraphRAG approaches lack a modular framework for systematic analysis, making it difficult to understand the trade-offs between different components and design optimal systems. This paper aims to fill this gap by providing a modular framework and conducting a comprehensive empirical study of GraphRAG design choices.

Methods

The core contribution is the LEGO-GraphRAG framework, which modularizes the GraphRAG process into two key phases:

  • Subgraph-Extraction (SE): This module aims to reduce the search space by extracting a query-relevant subgraph from the larger KG. It's further categorized into:
  • Structure-Based Extraction (SBE): Uses graph algorithms like Random Walk (RW), K-hop Subgraph-Extraction (KSE), and Personalized PageRank (PPR) to identify relevant nodes and edges based on graph topology.
  • Semantic-Augmented Extraction (SAE): Employs End-to-End Models (EEMs) or Large Language Models (LLMs) to assess the semantic relevance of graph components to the query.
  • Path-Retrieval (PR): This module retrieves reasoning paths from the extracted subgraph or the full graph. It's categorized into:
  • Structure-Based Retrieval (SBR): Uses graph traversal algorithms like Breadth-First Search (BFS), Depth-First Search (DFS), and Dijkstra's algorithm to find paths.
  • Semantic-Augmented Retrieval (OSAR/ISAR): Uses EEMs or LLMs to evaluate and select the most relevant paths. OSAR is one-way (retrieve then evaluate), while ISAR is interactive (integrates retrieval and evaluation).

The framework classifies GraphRAG instances into five groups based on combinations of these modules and method types. The authors also developed an implementation to facilitate this modular design and evaluation.

Datasets

The experiments were conducted on several large-scale, real-world knowledge graphs and query datasets:

  • Freebase: A large, multi-domain KG widely used in GraphRAG research.
  • Query Datasets: WebQSP, CWQ, GrailQA, and WebQuestions, covering diverse and challenging GraphRAG scenarios.
  • MetaQA: A non-Freebase dataset focused on movies, used to assess cross-base and cross-domain transferability.

Key Insights and Ideas

  • GraphRAG is a complex trade-off: Optimizing GraphRAG involves balancing quality (accuracy), efficiency (runtime), and cost (token/GPU usage) across modules, method types, and semantic models.
  • Subgraph-extraction is the bottleneck: This module is the primary efficiency bottleneck for large-scale graphs, and its optimization is crucial for practical GraphRAG systems.
  • Structure for efficiency, semantics for quality: Structure-based methods are generally more efficient and cost-effective, while semantic-augmented methods are essential for improving quality, especially for complex, multi-hop queries.
  • Path-retrieval is a sweet spot for semantics: Augmenting the path-retrieval module with semantic methods (especially OSAR) offers a better balance of quality and efficiency than augmenting subgraph-extraction.
  • EEMs vs. LLMs: EEMs are more cost-effective (tokens/GPU), while LLMs generally offer higher quality, particularly in interactive settings. However, LLMs can be unstable.
  • Underexplored strategy: Combining structure-based subgraph-extraction with semantic-augmented path-retrieval (OSAR) shows significant promise but is currently underexplored.

Key Results

  • Performance: Instances combining structure-based SE with semantic-augmented PR (OSAR/ISAR) generally achieve the best reasoning quality (Hits@1). For example, instances using EEMs for SE and OSAR for PR consistently outperformed others.
  • Runtime: Subgraph-extraction is significantly slower than path-retrieval, with PPR taking up to 75 seconds for large graphs. LLM-based path-retrieval (ISAR-LLMs) can also be very slow (over 100 seconds).
  • Cost: EEM-only setups are the most economical in terms of token and GPU usage. LLM-heavy setups can consume significant resources (up to 80GB GPU memory).
  • Query Complexity: Performance degrades with increased reasoning hops and answers. Semantic methods are more resilient to complexity than structure-based methods.
  • Hybrid ISAR: Combining EEMs and LLMs in ISAR (e.g., EEMs-S strategy) improved performance over single-model baselines.

Limitations and Future Work

  • Subgraph-extraction efficiency: While PPR is effective, its computational cost on very large graphs remains a challenge. Future work could explore distributed or approximate PPR, or precomputation strategies.
  • LLM instability: LLMs can produce unstable or low-quality outputs, affecting consistency. Strategies like multi-round LLMs (M-LLMs) and EEM supplementation (EEMs-S) can mitigate this but add overhead.
  • Underexplored combinations: The paper highlights the potential of combining structure-based SE with semantic-augmented PR, suggesting this as a promising direction for future research and optimization.
  • Handling complex queries: Further work is needed to improve performance on multi-hop and multi-answer queries, especially for structure-based methods.

Summary updated

BibTeX
@article{cao2024lego,
  author = {Yukun Cao and Zengyi Gao and Zhiyang Li and Xike Xie and S. Kevin Zhou},
  title = {{LEGO-GraphRAG: Modularizing Graph-based Retrieval-Augmented Generation for Design Space Exploration}},
  journal = {Proc. VLDB Endow.},
  year = {2024},
  url = {https://openreview.net/forum?id=FZMRJ2DOj0},
}
Figure