dgraphrag


Namedgraphrag JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryEnd-to-end GraphRAG toolkit that takes you from raw documents to a knowledge graph and then to retrieval-augmented generation (RAG) with large language models.
upload_time2025-07-11 07:22:25
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2025 Longtao Wu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords graph rag knowledge-graph retrieval llm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dgraphrag

👉 **Use the GraphRAG Accelerator**  
👉 **Read the docs**  
👉 **GraphRAG Arxiv**  

[![PyPI version](https://img.shields.io/pypi/v/dgraphrag.svg?logo=pypi)](https://pypi.org/project/dgraphrag/)  
[![Downloads](https://static.pepy.tech/badge/dgraphrag)](https://pepy.tech/project/dgraphrag)

---

## Overview

`dgraphrag` 是一个端到端 **GraphRAG** 工具包,帮助开发者从原始文本到知识图,再到 LLM 检索增强生成,串联完整流程并提供可插拔组件。
本项目由 [eust-w](https://github.com/eust-w) 发起,由 **D-Robotics**(<https://d-robotics.cc/>)开源。

要了解 GraphRAG 如何从非结构化数据中构建知识图并增强 LLM,请参考[官方文档](https://d-robotics.cc/docs)。

---

## Quickstart

```bash
pip install dgraphrag[neo4j,openai]         # 典型组合
dgrag ingest docs/                          # 构建图
dgrag ask "What is GraphRAG?"               # 提问
```

详细教程见 [docs/quickstart.md](docs/quickstart.md)。

---

## Repository Guidance

本仓库提供一个最小可行实现(MVP),方便你快速试用 GraphRAG 思路。请注意,默认索引构建与 LLM API 调用可能产生成本,使用前请理解相应流程及费用。

> ⚠️ **Warning:** `dgrag index` 可能在大规模数据时耗费较多资源,请先评估数据量与预算。

---

## Diving Deeper

- 了解核心概念与原理,阅读[设计文档](docs/design.md)  
- 想参与开发?请查看 [CONTRIBUTING.md](CONTRIBUTING.md)  
- 加入社区讨论:GitHub Discussions / Slack (#dgraphrag)

---

## Prompt Tuning

使用你自己的数据与 LLM 时,参考[提示工程指南](docs/prompt_tuning.md) 来微调或构建高质量 prompt。

---

## Versioning

版本遵循 *语义化版本* (SemVer)。重大变更请查看 [CHANGELOG.md](CHANGELOG.md)。  
使用前请始终运行:

```bash
dgrag info   # 检查当前索引版本与配置格式
```

---

## Responsible AI FAQ

详见 [RAI_TRANSPARENCY.md](RAI_TRANSPARENCY.md),其中解答了:

- GraphRAG 是什么?  
- 它能做些什么?  
- 潜在的局限与风险?  
- ……

---

## Trademarks

本项目可能包含第三方商标或徽标,其所有权归原持有人所有。本仓库仅出于学术与工程示范目的使用,不代表对这些商标或徽标的任何认可。

---

## Privacy

dgraphrag 不会在本地以外收集或存储任何用户数据;所有内容均在你的控制下处理。请在提交敏感数据前自行评估风险。

---
```bash
pip install dgraphrag[arangodb,tigergraph,vector]
# 或者开发模式
pip install -e .[arangodb,tigergraph,vector]
```

## Quick Start
```python
from pathlib import Path

from dgraphrag import (
    LocalTextLoader,
    SimpleParagraphSplitter,
    RegexExtractor,
    InMemoryGraphAdapter,
    SimpleGraphBuilder,
    BasicGraphRetriever,
)

# create a small demo file
Path("demo.txt").write_text("GraphRAG is RetrievalAugmentedGeneration.\n\nRetrievalAugmentedGeneration is Powerful.")

loader = LocalTextLoader()
text = loader.load("demo.txt")

paragraphs = SimpleParagraphSplitter().split(text)
triples = RegexExtractor().extract(paragraphs)

adapter = InMemoryGraphAdapter()
SimpleGraphBuilder(adapter).build(triples)

retriever = BasicGraphRetriever(adapter)
print(retriever.answer("What is GraphRAG?"))
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dgraphrag",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Longtao Wu <eustancewu@gmail.com>",
    "keywords": "graph, rag, knowledge-graph, retrieval, llm",
    "author": null,
    "author_email": "Longtao Wu <eustancewu@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/1c/e7/2d17c79510fdfaab14f56914b81271fe9ac01d746e56ebf9922e1e11f736/dgraphrag-0.0.2.tar.gz",
    "platform": null,
    "description": "# dgraphrag\n\n\ud83d\udc49 **Use the GraphRAG Accelerator**  \n\ud83d\udc49 **Read the docs**  \n\ud83d\udc49 **GraphRAG Arxiv**  \n\n[![PyPI version](https://img.shields.io/pypi/v/dgraphrag.svg?logo=pypi)](https://pypi.org/project/dgraphrag/)  \n[![Downloads](https://static.pepy.tech/badge/dgraphrag)](https://pepy.tech/project/dgraphrag)\n\n---\n\n## Overview\n\n`dgraphrag` \u662f\u4e00\u4e2a\u7aef\u5230\u7aef **GraphRAG** \u5de5\u5177\u5305\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u4ece\u539f\u59cb\u6587\u672c\u5230\u77e5\u8bc6\u56fe\uff0c\u518d\u5230 LLM \u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff0c\u4e32\u8054\u5b8c\u6574\u6d41\u7a0b\u5e76\u63d0\u4f9b\u53ef\u63d2\u62d4\u7ec4\u4ef6\u3002\n\u672c\u9879\u76ee\u7531 [eust-w](https://github.com/eust-w) \u53d1\u8d77\uff0c\u7531 **D-Robotics**\uff08<https://d-robotics.cc/>\uff09\u5f00\u6e90\u3002\n\n\u8981\u4e86\u89e3 GraphRAG \u5982\u4f55\u4ece\u975e\u7ed3\u6784\u5316\u6570\u636e\u4e2d\u6784\u5efa\u77e5\u8bc6\u56fe\u5e76\u589e\u5f3a LLM\uff0c\u8bf7\u53c2\u8003[\u5b98\u65b9\u6587\u6863](https://d-robotics.cc/docs)\u3002\n\n---\n\n## Quickstart\n\n```bash\npip install dgraphrag[neo4j,openai]         # \u5178\u578b\u7ec4\u5408\ndgrag ingest docs/                          # \u6784\u5efa\u56fe\ndgrag ask \"What is GraphRAG?\"               # \u63d0\u95ee\n```\n\n\u8be6\u7ec6\u6559\u7a0b\u89c1 [docs/quickstart.md](docs/quickstart.md)\u3002\n\n---\n\n## Repository Guidance\n\n\u672c\u4ed3\u5e93\u63d0\u4f9b\u4e00\u4e2a\u6700\u5c0f\u53ef\u884c\u5b9e\u73b0\uff08MVP\uff09\uff0c\u65b9\u4fbf\u4f60\u5feb\u901f\u8bd5\u7528 GraphRAG \u601d\u8def\u3002\u8bf7\u6ce8\u610f\uff0c\u9ed8\u8ba4\u7d22\u5f15\u6784\u5efa\u4e0e LLM API \u8c03\u7528\u53ef\u80fd\u4ea7\u751f\u6210\u672c\uff0c\u4f7f\u7528\u524d\u8bf7\u7406\u89e3\u76f8\u5e94\u6d41\u7a0b\u53ca\u8d39\u7528\u3002\n\n> \u26a0\ufe0f **Warning:** `dgrag index` \u53ef\u80fd\u5728\u5927\u89c4\u6a21\u6570\u636e\u65f6\u8017\u8d39\u8f83\u591a\u8d44\u6e90\uff0c\u8bf7\u5148\u8bc4\u4f30\u6570\u636e\u91cf\u4e0e\u9884\u7b97\u3002\n\n---\n\n## Diving Deeper\n\n- \u4e86\u89e3\u6838\u5fc3\u6982\u5ff5\u4e0e\u539f\u7406\uff0c\u9605\u8bfb[\u8bbe\u8ba1\u6587\u6863](docs/design.md)  \n- \u60f3\u53c2\u4e0e\u5f00\u53d1\uff1f\u8bf7\u67e5\u770b [CONTRIBUTING.md](CONTRIBUTING.md)  \n- \u52a0\u5165\u793e\u533a\u8ba8\u8bba\uff1aGitHub Discussions / Slack (#dgraphrag)\n\n---\n\n## Prompt Tuning\n\n\u4f7f\u7528\u4f60\u81ea\u5df1\u7684\u6570\u636e\u4e0e LLM \u65f6\uff0c\u53c2\u8003[\u63d0\u793a\u5de5\u7a0b\u6307\u5357](docs/prompt_tuning.md) \u6765\u5fae\u8c03\u6216\u6784\u5efa\u9ad8\u8d28\u91cf prompt\u3002\n\n---\n\n## Versioning\n\n\u7248\u672c\u9075\u5faa *\u8bed\u4e49\u5316\u7248\u672c* (SemVer)\u3002\u91cd\u5927\u53d8\u66f4\u8bf7\u67e5\u770b [CHANGELOG.md](CHANGELOG.md)\u3002  \n\u4f7f\u7528\u524d\u8bf7\u59cb\u7ec8\u8fd0\u884c\uff1a\n\n```bash\ndgrag info   # \u68c0\u67e5\u5f53\u524d\u7d22\u5f15\u7248\u672c\u4e0e\u914d\u7f6e\u683c\u5f0f\n```\n\n---\n\n## Responsible AI FAQ\n\n\u8be6\u89c1 [RAI_TRANSPARENCY.md](RAI_TRANSPARENCY.md)\uff0c\u5176\u4e2d\u89e3\u7b54\u4e86\uff1a\n\n- GraphRAG \u662f\u4ec0\u4e48\uff1f  \n- \u5b83\u80fd\u505a\u4e9b\u4ec0\u4e48\uff1f  \n- \u6f5c\u5728\u7684\u5c40\u9650\u4e0e\u98ce\u9669\uff1f  \n- \u2026\u2026\n\n---\n\n## Trademarks\n\n\u672c\u9879\u76ee\u53ef\u80fd\u5305\u542b\u7b2c\u4e09\u65b9\u5546\u6807\u6216\u5fbd\u6807\uff0c\u5176\u6240\u6709\u6743\u5f52\u539f\u6301\u6709\u4eba\u6240\u6709\u3002\u672c\u4ed3\u5e93\u4ec5\u51fa\u4e8e\u5b66\u672f\u4e0e\u5de5\u7a0b\u793a\u8303\u76ee\u7684\u4f7f\u7528\uff0c\u4e0d\u4ee3\u8868\u5bf9\u8fd9\u4e9b\u5546\u6807\u6216\u5fbd\u6807\u7684\u4efb\u4f55\u8ba4\u53ef\u3002\n\n---\n\n## Privacy\n\ndgraphrag \u4e0d\u4f1a\u5728\u672c\u5730\u4ee5\u5916\u6536\u96c6\u6216\u5b58\u50a8\u4efb\u4f55\u7528\u6237\u6570\u636e\uff1b\u6240\u6709\u5185\u5bb9\u5747\u5728\u4f60\u7684\u63a7\u5236\u4e0b\u5904\u7406\u3002\u8bf7\u5728\u63d0\u4ea4\u654f\u611f\u6570\u636e\u524d\u81ea\u884c\u8bc4\u4f30\u98ce\u9669\u3002\n\n---\n```bash\npip install dgraphrag[arangodb,tigergraph,vector]\n# \u6216\u8005\u5f00\u53d1\u6a21\u5f0f\npip install -e .[arangodb,tigergraph,vector]\n```\n\n## Quick Start\n```python\nfrom pathlib import Path\n\nfrom dgraphrag import (\n    LocalTextLoader,\n    SimpleParagraphSplitter,\n    RegexExtractor,\n    InMemoryGraphAdapter,\n    SimpleGraphBuilder,\n    BasicGraphRetriever,\n)\n\n# create a small demo file\nPath(\"demo.txt\").write_text(\"GraphRAG is RetrievalAugmentedGeneration.\\n\\nRetrievalAugmentedGeneration is Powerful.\")\n\nloader = LocalTextLoader()\ntext = loader.load(\"demo.txt\")\n\nparagraphs = SimpleParagraphSplitter().split(text)\ntriples = RegexExtractor().extract(paragraphs)\n\nadapter = InMemoryGraphAdapter()\nSimpleGraphBuilder(adapter).build(triples)\n\nretriever = BasicGraphRetriever(adapter)\nprint(retriever.answer(\"What is GraphRAG?\"))\n```\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 Longtao Wu\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "End-to-end GraphRAG toolkit that takes you from raw documents to a knowledge graph and then to retrieval-augmented generation (RAG) with large language models.",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/eust-w/dgraphrag",
        "Issues": "https://github.com/eust-w/dgraphrag/issues",
        "Repository": "https://github.com/eust-w/dgraphrag"
    },
    "split_keywords": [
        "graph",
        " rag",
        " knowledge-graph",
        " retrieval",
        " llm"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7fad658385f16e3ffccf36a2b77707bcf9a37561a3f61100166e7a1d4c7abd4c",
                "md5": "a4b325f73af31e05dc7dc40dcf21fd4b",
                "sha256": "fd3ab59051b66dbbae037b499a922b3b4fdec723804f4b05c8e3747ecc46ad66"
            },
            "downloads": -1,
            "filename": "dgraphrag-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a4b325f73af31e05dc7dc40dcf21fd4b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 20948,
            "upload_time": "2025-07-11T07:22:23",
            "upload_time_iso_8601": "2025-07-11T07:22:23.725086Z",
            "url": "https://files.pythonhosted.org/packages/7f/ad/658385f16e3ffccf36a2b77707bcf9a37561a3f61100166e7a1d4c7abd4c/dgraphrag-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1ce72d17c79510fdfaab14f56914b81271fe9ac01d746e56ebf9922e1e11f736",
                "md5": "7396edae3125115f4c559a52b71f383c",
                "sha256": "a3aebf1235fc2fdf9f874b2cf97134f2a7bb8bf3b7d6ffa664bbd13cab9a3e82"
            },
            "downloads": -1,
            "filename": "dgraphrag-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "7396edae3125115f4c559a52b71f383c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 18485,
            "upload_time": "2025-07-11T07:22:25",
            "upload_time_iso_8601": "2025-07-11T07:22:25.283691Z",
            "url": "https://files.pythonhosted.org/packages/1c/e7/2d17c79510fdfaab14f56914b81271fe9ac01d746e56ebf9922e1e11f736/dgraphrag-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-11 07:22:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "eust-w",
    "github_project": "dgraphrag",
    "github_not_found": true,
    "lcname": "dgraphrag"
}
        
Elapsed time: 0.42147s