Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
(AAAI 2026) Knowledge-Graph-Based Generation with Semantic Aggregation and Hierarchical Retrieval
| Date | Stars |
|---|---|
| 2026-07-31 | 256 |
| 2026-08-06 | 257 |
Today
+1 stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# LeanRAG: Knowledge-Graph-Based Generation with Semantic Aggregation and Hierarchical Retrieval
> 🎉 This paper has been **accepted by AAAI-26**! 🎉
[](https://www.python.org/downloads/) [](LICENSE) [](https://arxiv.org/abs/2508.10391)[](CONTRIBUTING.md)
LeanRAG is an efficient, open-source framework for Retrieval-Augmented Generation, leveraging knowledge graph structures with semantic aggregation and hierarchical retrieval to generate context-aware, concise, and high-fidelity responses.
## ✨ Features
- **Semantic Aggregation**: Clusters entities into semantically coherent summaries and constructs explicit relations to form a navigable aggregation-level knowledge network.
- **Hierarchical, Structure-Guided Retrieval**: Initiates retrieval from fine-grained entities and traverses up the knowledge graph to gather rich, highly relevant evidence efficiently.
- **Reduced Redundancy**: Optimizes retrieval paths to significantly reduce redundant information—LeanRAG achieves ~46% lower retrieval redundancy compared to flat retrieval baselines (based on benchmark evaluations).
- **Benchmark Performance**: Demonstrates superior performance across multiple QA benchmarks with improved response quality and retrieval efficiency.
## 🏛️ Architecture Overview

LeanRAG’s processing pipeline follows these core stages:
1. **Semantic Aggregation**
- Group low-level entities into clusters; generate summary nodes and build adjacency relations among them for efficient navigation.
2. **Knowledge Graph Construction**
- Construct a multi-layer graph where nodes represent entities and aggregated summaries, with explicit inter-node relations for graph-based traversal.
3. **Query Processing & Hierarchical Retrieval**
- Anchor queries at the most relevant detailed entities ("bottom-up"), then traverse upward through the semantic aggregation graph to collect evidence spans.
4. **Redundancy-Aware Synthesis**
- Streamline retrieval paths and avoid overlapping content, ensuring concise evidence aggregation before generating responses.
5. **Generation**
- Use retrieved, well-structured evidence as input to an LLM to produce coherent, accurate, and contextually grounded answers.
## 🚀 Getting Started
### Prerequisites
- Python 3.10+
- Conda for environment management
### Installation
1. **Clone the repository:**
```bash
git clone https://github.com/RaZzzyz/LeanRAG.git
cd LeanRAG
```
2. **Create a virtual environment:**
```bash
conda install -n leanrag python=3.11
conda activate leanrag
```
3. **Install the required dependencies:**
```bash
pip install -r requirements.txt
```
## 💻 Usage Workflow
Here’s a typical pipeline flow:
### **Step 1: Document Chunking**
In `file_chunk.py`, split the document into chunks:
- **Chunk size**: `1024`
- **Sliding step**: `128` (i.e., use a sliding window with step 128)
Each dictionary in the resulting `chunk` file contains two attributes:
- `hash_code`: hash calculated from the `text` content for traceability
- `text`: the chunk text content
---
### **Step 2: Extract Triples and Entity Descriptions**
Two knowledge graph extraction methods are currently provided:
#### **Method 1: CommonKG**
Based on Wikipedia entities. First, define a **head entity list**, then extract triples from the document.
**Usage:**
1. Edit the configuration file:
`CommonKG/config/create_kg_conf_test.yaml`
Fill in the model's `url` and `name`, and the path to the chunk file.
2. Run extraction:
```bash
python CommonKG/create_kg.py
```
The extraction result will be saved in output_dir.
3. Process 6-tuples with descriptioExcerpt of 15,332 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:41bdc65f31ede0ac, desc:knowledge graph