KnowledgeApr 2, 2026·3 min read

GraphRAG — Knowledge Graph RAG by Microsoft

Build knowledge graphs from documents for smarter RAG. Local and global search over entity relationships. By Microsoft Research. 31K+ stars.

TL;DR
GraphRAG indexes documents into knowledge graphs and provides local and global search over entity relationships.
§01

What it is

GraphRAG is an open-source tool by Microsoft Research that builds knowledge graphs from unstructured documents for smarter retrieval-augmented generation. Unlike traditional RAG that retrieves text chunks, GraphRAG extracts entities and relationships, organizing them into a graph structure that supports both entity-focused local search and holistic global search.

GraphRAG is designed for researchers and developers building RAG systems that need to answer questions requiring synthesis across multiple documents, not just finding a single relevant passage.

§02

How it saves time or tokens

Traditional vector-based RAG struggles with questions that span multiple documents or require understanding relationships between entities. GraphRAG solves this by pre-indexing documents into a knowledge graph during the indexing phase. At query time, the graph structure enables answering questions like 'what are the key themes across all documents' without scanning every chunk. The estimated token cost for this workflow is around 1,783 tokens.

§03

How to use

  1. Install GraphRAG:
pip install graphrag
  1. Initialize and index your documents:
graphrag init --root ./my-project
# Place documents in ./my-project/input/
graphrag index --root ./my-project
  1. Query with local or global search:
# Local search (entity-focused)
graphrag query --root ./my-project --method local \
  'What are the main findings about transformer architectures?'

# Global search (holistic summary)
graphrag query --root ./my-project --method global \
  'What are the key themes across all documents?'
§04

Example

# Python API usage
from graphrag.query.cli import run_local_search, run_global_search

# After indexing, query programmatically
result = run_local_search(
    root_dir='./my-project',
    query='Who are the key researchers in attention mechanisms?'
)
print(result.response)

# Global search for cross-document synthesis
result = run_global_search(
    root_dir='./my-project',
    query='Summarize the evolution of language models'
)
print(result.response)
§05

Related on TokRepo

§06

Common pitfalls

  • Not configuring the LLM provider in settings.yaml before running the indexing step
  • Running indexing on very large document sets without estimating the LLM API costs first
  • Using local search when the question requires cross-document synthesis (use global search instead)

Frequently Asked Questions

How does GraphRAG differ from traditional vector RAG?+

Traditional RAG splits documents into chunks and retrieves the most similar ones. GraphRAG extracts entities and relationships into a knowledge graph, enabling answers that require understanding connections across documents rather than finding a single relevant passage.

What are local and global search in GraphRAG?+

Local search finds information about specific entities and their relationships. Global search synthesizes themes and summaries across the entire document collection. Use local for factual lookups and global for high-level analysis.

How much does indexing cost in LLM API calls?+

Indexing cost depends on document volume and the LLM used. GraphRAG calls the LLM to extract entities and relationships from each text chunk. For large collections, costs can be significant. Test with a small subset first.

Can I use GraphRAG with local models?+

Yes. Configure the settings.yaml to point to a local model endpoint (e.g., Ollama, vLLM). This eliminates API costs but requires sufficient compute for entity extraction during indexing.

What document formats does GraphRAG support?+

GraphRAG processes plain text and PDF files placed in the input directory. For other formats, convert to text before indexing. The tool handles chunking and entity extraction automatically.

Citations (3)
🙏

Source & Thanks

Created by Microsoft Research. Licensed under MIT.

graphrag — ⭐ 31,900+

Thanks to Microsoft Research for advancing RAG with knowledge graph techniques.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets