Knowledge2026年4月2日·1 分钟阅读

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.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 27/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Knowledge
安装
Stage only
信任
信任等级:Community
入口
graphrag.md
安全暂存命令
npx -y tokrepo@latest install ac77668d-1767-4b86-ac8c-1c050166d21b --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

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)

常见问题

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.

引用来源 (3)
🙏

来源与感谢

Created by Microsoft Research. Licensed under MIT.

graphrag — ⭐ 31,900+

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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产