gusye1234/nano-graphrag
Embeddable Python GraphRAG for entity-centric retrieval and corpus-wide synthesis
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
nano-graphrag is an embeddable Python SDK built around the GraphRAG and QueryParam dataclasses. insert and ainsert chunk documents, use model calls to extract entities and relationships, and build a graph whose communities are summarized into reports. Local search starts from relevant entities and assembles graph context; global search synthesizes across community reports. The optional naive path retrieves text chunks by embedding similarity instead of using graph context at query time.
The SDK separates key-value, vector and graph storage. Its default setup combines file-backed KV storage, nano-vectordb and NetworkX; hnswlib and Neo4j are built-in options for the vector and graph layers respectively. Model completion and embedding functions are injectable. Completion is split into a stronger model for planning and responses and a cheaper one for summarization, defaulting to gpt-4o and gpt-4o-mini. The Python dependencies include OpenAI, tiktoken, NetworkX, graspologic and tenacity alongside the storage and provider packages.
Key Capabilities & Differentiators
A caller can insert a document or a batch of strings, reopen the same working_dir to load persisted state, and choose local, global or naive retrieval per query. Both ingestion and querying have async entry points. Queries normally return a completed answer without streaming; only_need_context=True returns the assembled context so the application can supply its own prompt or generation layer. Global search considers at most 512 communities by default, adjustable via QueryParam.global_max_consider_community.
OpenAI, Azure OpenAI and Amazon Bedrock have built-in integrations. Examples show DeepSeek and Ollama generation, local sentence-transformers embeddings, and FAISS and Milvus Lite vector adapters. Chunking functions and prompts are replaceable, and a custom response-to-JSON converter can handle backends whose structured output needs post-processing. GraphML provides a visualization path. English and Chinese benchmark materials and a multi-hop evaluation notebook offer starting points for comparing retrieval modes on a representative corpus.
Trade-offs & Limitations
Compared with Microsoft's GraphRAG, this implementation gives developers a smaller Python surface to modify, but it is not a drop-in replacement. It omits covariates and uses a capped set of important or central communities for global search rather than processing the full community set in the original map-reduce-like approach. That cap bounds how many reports enter consideration, but themes concentrated in lower-ranked communities can be missed. Test global coverage on the target corpus rather than treating the default as a quality guarantee.
MD5-based content keys prevent duplicate chunks, but inserts that add new content still recompute graph communities and regenerate their reports. On a frequently updated corpus, that turns ingestion cadence into a cost and latency decision; measure the effect of batching before committing to continuous ingestion. Use naive chunk retrieval as a baseline when plain passage lookup may suffice. Cloud APIs reduce local model operations but introduce provider costs and data-handling considerations; local models shift capacity planning and structured-output reliability back to the operator.
Hardware & Deployment Guide
Install the Python package from PyPI with pip install nano-graphrag or from a source checkout with pip install -e .. The integration point is an in-process Python API, not a packaged HTTP service. For the file-backed path, give the application a writable, durable working_dir. OpenAI requires an API key; Azure OpenAI needs its environment settings and using_azure_openai=True; Bedrock needs AWS credentials, using_amazon_bedrock=True, and model IDs. Neo4j is an optional graph backend, not a prerequisite.
The hosted path shifts model compute to the provider, but the application still budgets for graph processing, vector indexing, storage and API concurrency. The no-key example combines Ollama and transformers; local RAM and VRAM requirements depend on the selected models, context lengths, embedding batches and concurrency. In the release history, v0.0.6 fixed HNSW local-query bugs, v0.0.7 added naive chunk RAG, and v0.0.8, dated October 1, 2024, added Azure OpenAI and DSPy-based entity extraction.
GraphRAG and QueryParam are dataclasses; ainsert and aquery expose the async path.Python teams prototyping or embedding entity-centric retrieval and corpus-wide synthesis, with room to swap models and storage or compare against chunk retrieval.
You need parity with Microsoft's GraphRAG, a packaged streaming API, or frequent ingestion without community and report rebuilds.
Quick Start & Installation
# clone this repo first cd nano-graphrag pip install -e .
Comparison vs. Top RAG, Data & Memory Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| nano-graphrag ★ | 4k | +2 | Python | MIT | Embeddable Python GraphRAG for entity-centric retrieval and corpus-wide synthesi |
| llama_index | 53.1k | +104 | Python | MIT | A modular Python SDK for document ingestion, indexing, and RAG |
| haystack | 27.2k | +53 | Python | Apache-2.0 | Component-based Python orchestration for RAG pipelines and tool-using agents |
| auto-ontology | 19.1k | +3.7k | Python | Apache-2.0 | An ontology framework that grounds agent-generated SQL in reviewed business defi |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/gusye1234/nano-graphrag.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about nano-graphrag
How do I integrate nano-graphrag into an async Python service?
GraphRAG.ainsert and GraphRAG.aquery from async application code, and set QueryParam(only_need_context=True) if the application owns prompt assembly or answer generation. The normal query interface returns a complete answer rather than a token stream. Keep the same working_dir to reload persisted state with the default setup.Do I need a GPU, and what should I size the runtime for?
Can I use it commercially and keep document processing on premises?
When should I use nano-graphrag instead of Microsoft's GraphRAG or vector-only RAG?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy