Overview
GraphRAG is a modular graph-based Retrieval-Augmented Generation (RAG) system developed by Microsoft Research. It extracts meaningful, structured data from unstructured text using LLMs to create a knowledge graph, then uses these connections to answer questions that span many documents or require thematic understanding. Unlike traditional vector-based RAG, GraphRAG excels at answering abstract questions like "What are the top themes in this dataset?" by leveraging community detection and hierarchical summarization.
Problem Addressed
| Problem |
Solution |
| Vector/keyword search fails on cross-document questions |
Knowledge graph connects information across large volumes of documents |
| Thematic questions unanswerable with traditional RAG |
Community detection and hierarchical summarization enable abstract reasoning |
| RAG limited to local context around retrieved chunks |
Global search via map-reduce over community reports provides dataset overview |
| Noisy data with conflicting information |
Graph structure surfaces relationships and identifies authoritative entities |
| Single retrieval strategy limits flexibility |
Multiple search modes: Local, Global, DRIFT, Basic for different query types |
| LLM costs high for re-indexing on errors |
Built-in LLM caching prevents redundant API calls during indexing |
| Lock-in to specific storage or model providers |
Factory pattern allows custom implementations for all subsystems |
Key Statistics
| Metric |
Value |
Date Gathered |
| GitHub Stars |
30,637 |
2026-01-31 |
| GitHub Forks |
3,229 |
2026-01-31 |
| Open Issues |
95 |
2026-01-31 |
| PyPI Monthly DL |
60,312 |
2026-01-31 |
| PyPI Weekly DL |
19,803 |
2026-01-31 |
| PyPI Daily DL |
4,051 |
2026-01-31 |
| Primary Language |
Python |
2026-01-31 |
| Repository Age |
Since March 2024 |
2026-01-31 |
| Python Required |
>=3.11, <3.14 |
2026-01-31 |
Key Features
Indexing Pipeline
- Entity extraction: LLM-powered extraction of entities, relationships, and claims from raw text
- Community detection: Graph-based clustering to identify related entity communities
- Hierarchical summarization: Community reports generated at multiple levels of granularity
- Chunk embedding: Text chunks embedded for vector similarity search
- Entity embedding: Entities embedded for semantic retrieval
- LLM caching: Cached completions for idempotent, resilient indexing
- Configurable workflows: Modular pipeline with customizable steps and prompts
Query Mechanisms
- Local Search: Combines AI-extracted knowledge graph with text chunks for entity-specific questions
- Global Search: Map-reduce over community reports for dataset-wide thematic questions
- DRIFT Search: Expands local search breadth using community insights for comprehensive answers
- Basic Search: Vector RAG baseline for comparison (top-k chunk retrieval)
- Question Generation: Generates follow-up questions for deeper investigation
Architecture
- Monorepo structure: Modular packages (graphrag-cache, graphrag-chunking, graphrag-common, graphrag-input, graphrag-llm, graphrag-storage, graphrag-vectors)
- Factory pattern: Extensible providers for models, storage, cache, vectors, input readers
- Parquet outputs: Indexes stored as Parquet tables for efficient querying
- CLI and Python API: Multiple interfaces for indexing and querying
Model Support
- OpenAI: Direct API integration
- Azure OpenAI: Full support with managed identity authentication
- LiteLLM wrapper: Extensible to additional providers
- Prompt tuning: Guidance for domain-specific prompt optimization
Storage Backends
- File storage: Local filesystem for development
- Azure Blob Storage: Cloud storage integration
- CosmosDB: Distributed database support
- Vector stores: LanceDB, Azure AI Search, CosmosDB vector search
Technical Architecture
Pipeline Flow
Knowledge Model
| Component |
Description |
| Documents |
Source text files (txt, CSV, JSON) |
| Text Units |
Chunked document segments |
| Entities |
Extracted named entities (people, places, things) |
| Relationships |
Connections between entities |
| Claims |
Factual assertions extracted from text |
| Communities |
Clusters of related entities from graph analysis |
| Community Reports |
LLM-generated summaries at multiple hierarchy levels |
| Embeddings |
Vector representations for semantic search |
Factory Extensions
| Subsystem |
Purpose |
Built-in Options |
| Language Model |
Chat and embed methods |
LiteLLM wrapper (OpenAI, Azure, etc.) |
| Input Reader |
Document ingestion |
Text, CSV, JSON |
| Cache |
LLM response caching |
File, Blob, CosmosDB |
| Storage |
Index persistence |
File, Blob, CosmosDB |
| Vector Store |
Embedding storage and retrieval |
LanceDB, Azure AI Search, CosmosDB |
| Workflows |
Pipeline step customization |
Default GraphRAG pipeline |
Installation and Usage
Installation
# Using pip
pip install graphrag
# Using uv
uv pip install graphrag
Quick Start
# Initialize workspace
mkdir graphrag_project && cd graphrag_project
graphrag init
# Configure API key in .env
# GRAPHRAG_API_KEY=<your-api-key>
# Add documents to ./input directory
curl https://www.gutenberg.org/cache/epub/24022/pg24022.txt -o ./input/book.txt
# Run indexing
graphrag index
# Query with Global Search (thematic questions)
graphrag query "What are the top themes in this story?"
# Query with Local Search (entity-specific questions)
graphrag query "Who is Scrooge and what are his main relationships?" --method local
Python API
from graphrag.api import build_index, local_search, global_search
# Index documents
await build_index(root="./graphrag_project")
# Local search for entity questions
result = await local_search(
root="./graphrag_project",
query="What are the healing properties of chamomile?"
)
# Global search for thematic questions
result = await global_search(
root="./graphrag_project",
query="What are the main themes across all documents?"
)
Azure OpenAI Configuration
# settings.yaml
models:
default_chat_model:
type: chat
model_provider: azure
model: gpt-4.1
deployment_name: <AZURE_DEPLOYMENT_NAME>
api_base: https://<instance>.openai.azure.com
api_version: 2024-02-15-preview
auth_type: azure_managed_identity # Optional: for managed auth
Relevance to Claude Code Development
Direct Applications
Knowledge-Augmented Skills: GraphRAG patterns could inform how Claude Code skills organize and retrieve reference documentation, using graph structure instead of flat files.
Cross-Document Reasoning: The community detection and hierarchical summarization approach provides a model for answering questions that span multiple skill reference files.
Thematic Query Support: Global search mechanism could inspire how Claude Code answers abstract questions about a codebase ("What patterns does this project follow?").
Context Window Optimization: Community reports provide compressed summaries that could reduce token usage while maintaining comprehensive coverage.
Caching Patterns: LLM caching strategy applicable to Claude Code for expensive operations.
Patterns Worth Adopting
Multiple Search Strategies: Local vs Global vs DRIFT search demonstrates value of query-type-specific retrieval strategies.
Community Detection: Graph clustering to identify related concepts could improve skill organization and cross-referencing.
Hierarchical Summarization: Multi-level community reports enable both detailed and overview queries on same index.
Factory Pattern: Extensible providers for all subsystems enable customization without core changes.
Parquet Outputs: Columnar format for index storage enables efficient analytical queries.
Integration Opportunities
MCP Server: GraphRAG could be exposed as an MCP tool for Claude Code to query indexed knowledge bases.
Skill Indexing: Index skill reference documentation with GraphRAG for enhanced retrieval in complex multi-skill queries.
Codebase Understanding: Index codebase documentation/comments to answer architectural questions.
Research Aggregation: Index research entries (like this one) for cross-resource thematic queries.
Comparison: GraphRAG vs Traditional RAG
| Aspect |
GraphRAG |
Traditional Vector RAG |
| Cross-document reasoning |
Strong (graph connections) |
Weak (isolated chunks) |
| Thematic/abstract queries |
Strong (community reports) |
Weak (no global context) |
| Entity-specific queries |
Strong (local search + graph) |
Moderate (chunk retrieval) |
| Indexing cost |
High (LLM-intensive extraction) |
Low (embedding only) |
| Query latency |
Higher (map-reduce for global) |
Lower (single retrieval) |
| Storage requirements |
Higher (graph + reports + embeddings) |
Lower (embeddings only) |
| Update complexity |
Higher (re-extraction) |
Lower (re-embed changed docs) |
Cost Considerations
The README explicitly warns: "GraphRAG indexing can be an expensive operation." Best practices:
- Start with small test datasets
- Use inexpensive/fast models for initial experimentation
- Leverage LLM caching to avoid redundant API calls
- Consider update strategies before large indexing jobs
References
Research Method: Information gathered from official GitHub repository README, RAI transparency document, documentation pages (query overview, index overview, architecture), GitHub API for statistics, PyPI API for package info and download statistics. All claims verified against primary sources.
1---2name: microsoft-graphrag3description: GraphRAG is a modular graph-based Retrieval-Augmented Generation (RAG) system developed by Microsoft Research. It extracts meaningful, structured data from unstructured text using LLMs to create a...4license: MIT5---6
7## Overview
8
9GraphRAG is a modular graph-based Retrieval-Augmented Generation (RAG) system developed by Microsoft Research. It extracts meaningful, structured data from unstructured text using LLMs to create a knowledge graph, then uses these connections to answer questions that span many documents or require thematic understanding. Unlike traditional vector-based RAG, GraphRAG excels at answering abstract questions like "What are the top themes in this dataset?" by leveraging community detection and hierarchical summarization.
10
11---
12
13## Problem Addressed
14
15| Problem | Solution |
16| ------------------------------------------------------- | ----------------------------------------------------------------------------- |
17| Vector/keyword search fails on cross-document questions | Knowledge graph connects information across large volumes of documents |
18| Thematic questions unanswerable with traditional RAG | Community detection and hierarchical summarization enable abstract reasoning |
19| RAG limited to local context around retrieved chunks | Global search via map-reduce over community reports provides dataset overview |
20| Noisy data with conflicting information | Graph structure surfaces relationships and identifies authoritative entities |
21| Single retrieval strategy limits flexibility | Multiple search modes: Local, Global, DRIFT, Basic for different query types |
22| LLM costs high for re-indexing on errors | Built-in LLM caching prevents redundant API calls during indexing |
23| Lock-in to specific storage or model providers | Factory pattern allows custom implementations for all subsystems |
24
25---
26
27## Key Statistics
28
29| Metric | Value | Date Gathered |
30| ---------------- | ---------------- | ------------- |
31| GitHub Stars | 30,637 | 2026-01-31 |
32| GitHub Forks | 3,229 | 2026-01-31 |
33| Open Issues | 95 | 2026-01-31 |
34| PyPI Monthly DL | 60,312 | 2026-01-31 |
35| PyPI Weekly DL | 19,803 | 2026-01-31 |
36| PyPI Daily DL | 4,051 | 2026-01-31 |
37| Primary Language | Python | 2026-01-31 |
38| Repository Age | Since March 2024 | 2026-01-31 |
39| Python Required | >=3.11, <3.14 | 2026-01-31 |
40
41---
42
43## Key Features
44
45### Indexing Pipeline
46
47- **Entity extraction**: LLM-powered extraction of entities, relationships, and claims from raw text
48- **Community detection**: Graph-based clustering to identify related entity communities
49- **Hierarchical summarization**: Community reports generated at multiple levels of granularity
50- **Chunk embedding**: Text chunks embedded for vector similarity search
51- **Entity embedding**: Entities embedded for semantic retrieval
52- **LLM caching**: Cached completions for idempotent, resilient indexing
53- **Configurable workflows**: Modular pipeline with customizable steps and prompts
54
55### Query Mechanisms
56
57- **Local Search**: Combines AI-extracted knowledge graph with text chunks for entity-specific questions
58- **Global Search**: Map-reduce over community reports for dataset-wide thematic questions
59- **DRIFT Search**: Expands local search breadth using community insights for comprehensive answers
60- **Basic Search**: Vector RAG baseline for comparison (top-k chunk retrieval)
61- **Question Generation**: Generates follow-up questions for deeper investigation
62
63### Architecture
64
65- **Monorepo structure**: Modular packages (graphrag-cache, graphrag-chunking, graphrag-common, graphrag-input, graphrag-llm, graphrag-storage, graphrag-vectors)
66- **Factory pattern**: Extensible providers for models, storage, cache, vectors, input readers
67- **Parquet outputs**: Indexes stored as Parquet tables for efficient querying
68- **CLI and Python API**: Multiple interfaces for indexing and querying
69
70### Model Support
71
72- **OpenAI**: Direct API integration
73- **Azure OpenAI**: Full support with managed identity authentication
74- **LiteLLM wrapper**: Extensible to additional providers
75- **Prompt tuning**: Guidance for domain-specific prompt optimization
76
77### Storage Backends
78
79- **File storage**: Local filesystem for development
80- **Azure Blob Storage**: Cloud storage integration
81- **CosmosDB**: Distributed database support
82- **Vector stores**: LanceDB, Azure AI Search, CosmosDB vector search
83
84---
85
86## Technical Architecture
87
88### Pipeline Flow
89
90<eg>
91Load Documents
92 |
93Chunk Documents
94 |
95 +-- Extract Graph --> Detect Communities --> Generate Reports --> Embed Reports
96 |
97 +-- Extract Claims
98 |
99 +-- Embed Chunks
100 |
101 +-- Embed Entities
102</eg>
103
104### Knowledge Model
105
106| Component | Description |
107| ----------------- | ---------------------------------------------------- |
108| Documents | Source text files (txt, CSV, JSON) |
109| Text Units | Chunked document segments |
110| Entities | Extracted named entities (people, places, things) |
111| Relationships | Connections between entities |
112| Claims | Factual assertions extracted from text |
113| Communities | Clusters of related entities from graph analysis |
114| Community Reports | LLM-generated summaries at multiple hierarchy levels |
115| Embeddings | Vector representations for semantic search |
116
117### Factory Extensions
118
119| Subsystem | Purpose | Built-in Options |
120| -------------- | ------------------------------- | ------------------------------------- |
121| Language Model | Chat and embed methods | LiteLLM wrapper (OpenAI, Azure, etc.) |
122| Input Reader | Document ingestion | Text, CSV, JSON |
123| Cache | LLM response caching | File, Blob, CosmosDB |
124| Storage | Index persistence | File, Blob, CosmosDB |
125| Vector Store | Embedding storage and retrieval | LanceDB, Azure AI Search, CosmosDB |
126| Workflows | Pipeline step customization | Default GraphRAG pipeline |
127
128---
129
130## Installation and Usage
131
132### Installation
133
134```bash
135# Using pip
136pip install graphrag
137
138# Using uv
139uv pip install graphrag
140```
141
142### Quick Start
143
144```bash
145# Initialize workspace
146mkdir graphrag_project && cd graphrag_project
147graphrag init
148
149# Configure API key in .env
150# GRAPHRAG_API_KEY=<your-api-key>
151
152# Add documents to ./input directory
153curl https://www.gutenberg.org/cache/epub/24022/pg24022.txt -o ./input/book.txt
154
155# Run indexing
156graphrag index
157
158# Query with Global Search (thematic questions)
159graphrag query "What are the top themes in this story?"
160
161# Query with Local Search (entity-specific questions)
162graphrag query "Who is Scrooge and what are his main relationships?" --method local
163```
164
165### Python API
166
167```python
168from graphrag.api import build_index, local_search, global_search
169
170# Index documents
171await build_index(root="./graphrag_project")
172
173# Local search for entity questions
174result = await local_search(
175 root="./graphrag_project",
176 query="What are the healing properties of chamomile?"
177)
178
179# Global search for thematic questions
180result = await global_search(
181 root="./graphrag_project",
182 query="What are the main themes across all documents?"
183)
184```
185
186### Azure OpenAI Configuration
187
188```yaml
189# settings.yaml
190models:
191 default_chat_model:
192 type: chat
193 model_provider: azure
194 model: gpt-4.1
195 deployment_name: <AZURE_DEPLOYMENT_NAME>
196 api_base: https://<instance>.openai.azure.com
197 api_version: 2024-02-15-preview
198 auth_type: azure_managed_identity # Optional: for managed auth
199```
200
201---
202
203## Relevance to Claude Code Development
204
205### Direct Applications
206
2071. **Knowledge-Augmented Skills**: GraphRAG patterns could inform how Claude Code skills organize and retrieve reference documentation, using graph structure instead of flat files.
208
2092. **Cross-Document Reasoning**: The community detection and hierarchical summarization approach provides a model for answering questions that span multiple skill reference files.
210
2113. **Thematic Query Support**: Global search mechanism could inspire how Claude Code answers abstract questions about a codebase ("What patterns does this project follow?").
212
2134. **Context Window Optimization**: Community reports provide compressed summaries that could reduce token usage while maintaining comprehensive coverage.
214
2155. **Caching Patterns**: LLM caching strategy applicable to Claude Code for expensive operations.
216
217### Patterns Worth Adopting
218
2191. **Multiple Search Strategies**: Local vs Global vs DRIFT search demonstrates value of query-type-specific retrieval strategies.
220
2212. **Community Detection**: Graph clustering to identify related concepts could improve skill organization and cross-referencing.
222
2233. **Hierarchical Summarization**: Multi-level community reports enable both detailed and overview queries on same index.
224
2254. **Factory Pattern**: Extensible providers for all subsystems enable customization without core changes.
226
2275. **Parquet Outputs**: Columnar format for index storage enables efficient analytical queries.
228
229### Integration Opportunities
230
2311. **MCP Server**: GraphRAG could be exposed as an MCP tool for Claude Code to query indexed knowledge bases.
232
2332. **Skill Indexing**: Index skill reference documentation with GraphRAG for enhanced retrieval in complex multi-skill queries.
234
2353. **Codebase Understanding**: Index codebase documentation/comments to answer architectural questions.
236
2374. **Research Aggregation**: Index research entries (like this one) for cross-resource thematic queries.
238
239### Comparison: GraphRAG vs Traditional RAG
240
241| Aspect | GraphRAG | Traditional Vector RAG |
242| ------------------------- | ------------------------------------- | ----------------------------- |
243| Cross-document reasoning | Strong (graph connections) | Weak (isolated chunks) |
244| Thematic/abstract queries | Strong (community reports) | Weak (no global context) |
245| Entity-specific queries | Strong (local search + graph) | Moderate (chunk retrieval) |
246| Indexing cost | High (LLM-intensive extraction) | Low (embedding only) |
247| Query latency | Higher (map-reduce for global) | Lower (single retrieval) |
248| Storage requirements | Higher (graph + reports + embeddings) | Lower (embeddings only) |
249| Update complexity | Higher (re-extraction) | Lower (re-embed changed docs) |
250
251### Cost Considerations
252
253The README explicitly warns: "GraphRAG indexing can be an expensive operation." Best practices:
254
255- Start with small test datasets
256- Use inexpensive/fast models for initial experimentation
257- Leverage LLM caching to avoid redundant API calls
258- Consider update strategies before large indexing jobs
259
260---
261
262## References
263
264| Source | URL | Accessed |
265| -------------------------- | ----------------------------------------------------------------------------------------------------------- | ---------- |
266| GitHub Repository | <https://github.com/microsoft/graphrag> | 2026-01-31 |
267| Official Documentation | <https://microsoft.github.io/graphrag/> | 2026-01-31 |
268| arXiv Paper | <https://arxiv.org/pdf/2404.16130> | 2026-01-31 |
269| Microsoft Research Blog | <https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/> | 2026-01-31 |
270| PyPI Package | <https://pypi.org/project/graphrag/> | 2026-01-31 |
271| PyPI Stats | <https://pypistats.org/packages/graphrag> | 2026-01-31 |
272| RAI Transparency Document | <https://github.com/microsoft/graphrag/blob/main/RAI_TRANSPARENCY.md> | 2026-01-31 |
273| Query Engine Documentation | <https://microsoft.github.io/graphrag/query/overview/> | 2026-01-31 |
274| Indexing Documentation | <https://microsoft.github.io/graphrag/index/overview/> | 2026-01-31 |
275| Architecture Documentation | <https://microsoft.github.io/graphrag/index/architecture/> | 2026-01-31 |
276
277**Research Method**: Information gathered from official GitHub repository README, RAI transparency document, documentation pages (query overview, index overview, architecture), GitHub API for statistics, PyPI API for package info and download statistics. All claims verified against primary sources.