LeanRAG: Knowledge-Graph-Based Generation with Semantic Aggregation and Hierarchical Retrieval

Yaoze Zhang, Rong Wu, Pinlong Cai, Xiaoman Wang, Guohang Yan, Song Mao, Ding Wang 0001, Botian Shi

TL;DR

LeanRAG is a novel knowledge-graph-based Retrieval-Augmented Generation (RAG) framework that solves the dual challenges of disconnected high-level summaries ("semantic islands") and structurally blind retrieval in hierarchical RAG systems. By automatically generating explicit relations between abstract summary clusters and using a bottom-up Lowest Common Ancestor (LCA) path traversal strategy, LeanRAG significantly boosts answer quality while slashing retrieval token redundancy by 46% on average.


What Problem Does This Paper Address?

Standard RAG systems struggle with the "chunking dilemma": small text chunks lose critical context, while large chunks introduce noise that dilutes an LLM's focus. To fix this, researchers turned to Knowledge Graphs (KGs). Early graph-based RAG methods group documents into communities, but often retrieve massive, coarse-grained summaries that contain significant redundancy.

More advanced hierarchical methods cluster entities into multi-level summaries to allow fine-grained control. However, the authors identify two critical flaws in current state-of-the-art hierarchical RAG approaches:

  1. Semantic Islands: High-level conceptual summaries exist in isolation. They lack explicit relational connections between each other, making cross-community reasoning difficult.
  2. Structural Unawareness: At query time, the retrieval process often flattens the hierarchy into a simple semantic search over a list of nodes, completely ignoring the rich topological information encoded in the graph.
Comparison of typical LLM retrieval-augmented generation frameworks.

Methods

LeanRAG tightly co-designs its knowledge structuring (aggregation) and retrieval mechanisms to create a fully navigable, efficient semantic network.

1. Hierarchical Knowledge Graph Aggregation

LeanRAG builds a multi-layered hierarchy from a base knowledge graph in a bottom-up fashion:

  • Recursive Semantic Clustering: Entity descriptions are converted into dense vectors using a pre-trained embedding model, and a Gaussian Mixture Model (GMM) partitions them into semantically coherent clusters.
  • Aggregated Entity Generation: For each cluster, an LLM synthesizes a single, abstract parent entity and a comprehensive description summarizing its components.
  • Aggregated Relation Generation: To connect "semantic islands," LeanRAG calculates the connectivity strength ($\lambda$) between clusters. If it exceeds a dynamic threshold ($\tau$), an LLM infers a meaningful high-level relationship between the abstract parent nodes.

2. Structured Retrieval via Lowest Common Ancestor (LCA)

Instead of searching over a flattened graph, LeanRAG uses a structure-aware, bottom-up strategy:

  • Initial Entity Anchoring: The query is first matched against the most specific, fine-grained entities at the base layer (leaf level) to find the top-$n$ "seed entities."
  • LCA Path Traversal: The system identifies the Lowest Common Ancestor (LCA) in the hierarchy for these seed entities. It then extracts the minimal subgraph connecting the seeds to their shared abstract concepts. This avoids the retrieval of massive, irrelevant intermediate nodes.
Overview of the LeanRAG framework.

Datasets

The authors evaluated LeanRAG using four distinct datasets from the UltraDomain benchmark, which focuses on long-context tasks and high-level queries in specialized fields:

  • Mix: A general collection of 61 documents (~626k tokens).
  • CS (Computer Science): Technical documents consisting of 10 documents (~2.21M tokens).
  • Legal: Highly specialized and dense legal texts spanning 94 documents (~5.28M tokens).
  • Agriculture: Domain-specific data containing 12 documents (~2.03M tokens).

Key Insights and Ideas

  • Inter-Cluster Relations are Crucial: Generating explicit edges between abstract summary nodes transforms isolated hierarchical trees into a unified, navigable semantic network. Ablation studies showed that removing these relations significantly hurts retrieval diversity.
  • Topology-Aware Retrieval Beats Flat Search: Navigating the graph via LCA paths radically reduces the search space. Instead of pulling in entire text communities, LeanRAG extracts a precise, compact evidence backbone.
  • Structured Graphs Guide, Unstructured Text Informs: A key finding is that structured graph entities alone are insufficient for final generation. The original raw text chunks linked to the base entities must be returned to provide the narrative richness and detailed explanations an LLM needs to generate thorough answers.

Key Results

LeanRAG was compared against several prominent baselines, including NaiveRAG, GraphRAG, LightRAG, KAG, FastGraphRAG, and HiRAG, using an LLM judge to score answers from 1 to 10 across multiple dimensions.

  • Superior Quality: LeanRAG consistently outperformed or matched the state-of-the-art across all datasets in Comprehensiveness, Empowerment, Diversity, and Overall Quality.
  • Massive Efficiency Gains: LeanRAG achieved these results while retrieving a substantially more compact context. On average, its retrieved context size was 46% smaller than the baselines, dramatically lowering token consumption.
Comparison in retrieval tokens across four datasets.

Limitations and Future Work

While LeanRAG demonstrates impressive token efficiency and response quality, the authors note a few areas for improvement:

  • Static Hyperparameters: The clustersize (manually limited to 20 nodes per cluster) and the relation threshold ($\tau = 3$) were kept uniform across all datasets. Future work will explore dynamically adjusting these parameters based on graph density and domain characteristics.
  • LLM Dependency during Indexing: The framework relies heavily on LLM prompts to generate abstract entities and relations during the graph-building phase, which can introduce computational overhead and API costs at scale.

Loading related content...