
GraphRAG
文書群から知識グラフを構築し、コーパス全体に関する問いに答えられるようにする手法の実装
GraphRAGとは
通常の検索は質問に似たチャンクを探すため、答えがどのチャンクにも書かれていない問い、たとえば全体の主題や2人の人物の関係といった問いには答えられません。GraphRAGは各文章から実体・関係・主張を抽出し、できたグラフをコミュニティに分割して要約し、その要約から回答します。代償は索引の構築時に支払われます。すべてのテキスト単位に対して、さらにすべてのコミュニティに対してモデルを走らせるため、構築コストは質問の回数ではなくコーパスの規模に比例します。
GraphRAGで何ができますか?
- どの文章にも書かれていない問いに答える — グローバル検索は取得したチャンクではなくコミュニティの要約から回答します。繰り返し現れる主題や、複数の報告書をまたいで何が変わったかといったコーパス全体の問いに答えられるのはこの仕組みによります。
- 特定の実体から辿る — ローカル検索は指定した実体を起点に、その隣接関係や関連概念を探索します。ある人物・製品・場所についての質問で、最も似た段落ではなく散在する言及を集められます。
- 導出されたグラフを確認できる — 索引の構築結果は、実体・関係・主張というデータとして見られます。誤った回答を、埋め込みの中に消えた原因ではなく、誤った抽出として追跡できます。
- 階層のあらゆる粒度で要約を持つ — Leiden法でグラフをコミュニティに分割し、要約は下位から順に生成されます。1つの索引から、細かい粒度の視点とコーパス全体の視点の両方が得られます。
- 抽出の基準を対象領域に合わせる — 何を実体とみなし何を主張とみなすかを決めるプロンプトは、調整される前提で置かれています。ドキュメントはプロンプト調整を後回しの最適化ではなく初期設定の一部として扱っています。
GraphRAGを選ぶ前に
- 抽出時にすべてのテキスト単位へ、要約時にすべてのコミュニティへモデルを走らせるため、索引構築の費用は質問数ではなくコーパスの規模に比例します。
- ドキュメント自身が、通常の検索では点と点が繋がらない場面向けと位置づけています。中規模のコーパスでの単純な検索なら、従来の検索のほうが安く単純なままです。
スター推移
8月21日〜8月28日 · +106
よくある質問
GraphRAGは商用利用できますか?
GraphRAGはMITライセンスで公開されています。OSI承認のオープンソースライセンスで、商用利用が認められています。
GraphRAGはどの形で使えますか?
GraphRAGはセルフホスト・ローカル実行の形で利用できます。
ドキュメント
microsoft/graphrag のREADMEより転載(MIT)。 原文を読む ↗
GraphRAG
[!WARNING] GraphRAG is a research project that explores the functional use of graphs to form a targeted context for question answering. Since our first release in July 2024 the capabilities of frontier models have changed dramatically, and our portfolio of research projects has diversified to match. This project is largely in maintenance mode, and won’t be accepting new PRs or implementing new features. We’ll perform bug fixes and dependency updates as appropriate, particularly to address CVEs as they arise.
👉 Microsoft Research Blog Post 👉 Read the docs 👉 GraphRAG Arxiv
Overview
The GraphRAG project is a data pipeline and transformation suite that is designed to extract meaningful, structured data from unstructured text using the power of LLMs.
To learn more about GraphRAG and how it can be used to enhance your LLM’s ability to reason about your private data, please visit the Microsoft Research Blog Post.
Quickstart
To get started with the GraphRAG system we recommend trying the command line quickstart.
Repository Guidance
This repository presents a methodology for using knowledge graph memory structures to enhance LLM outputs. Please note that the provided code serves as a demonstration and is not an officially supported Microsoft offering.
⚠️ Warning: GraphRAG indexing can be an expensive operation, please read all of the documentation to understand the process and costs involved, and start small.
Diving Deeper
- To learn about our contribution guidelines, see CONTRIBUTING.md
- To start developing GraphRAG, see DEVELOPING.md
- Join the conversation and provide feedback in the GitHub Discussions tab!
Prompt Tuning
Using GraphRAG with your data out of the box may not yield the best possible results. We strongly recommend to fine-tune your prompts following the Prompt Tuning Guide in our documentation.
Versioning
Please see the breaking changes document for notes on our approach to versioning the project.
Always run graphrag init --root [path] --force between minor version bumps to ensure you have the latest config format. Run the provided migration notebook between major version bumps if you want to avoid re-indexing prior datasets. Note that this will overwrite your configuration and prompts, so back them up if necessary.
Responsible AI FAQ
- What is GraphRAG?
- What can GraphRAG do?
- What are GraphRAG’s intended use(s)?
- How was GraphRAG evaluated? What metrics are used to measure performance?
- What are the limitations of GraphRAG? How can users minimize the impact of GraphRAG’s limitations when using the system?
- What operational factors and settings allow for effective and responsible use of GraphRAG?
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.