circlemind fast-graphrag

Streamlined and promptable Fast GraphRAG framework designed for interpretable, high-precision, agent-driven retrieval workflows.

精简且可提示的快速 GraphRAG 框架,专为可解释、高精度、代理驱动的检索工作流程而设计。(Streamlined and promptable Fast GraphRAG framework designed for interpretable, high-precision, agent-driven retrieval workflows.)

Install | Quickstart | Community | Report Bug | Request Feature

安装 (Install) | 快速入门 (Quickstart) | 社区 (Community) | 报告错误 (Report Bug) | 请求功能 (Request Feature)

[!NOTE] Using The Wizard of Oz, fast-graphrag costs $0.08 vs. graphrag $0.48 — a 6x costs saving that further improves with data size and number of insertions.

[!NOTE] 使用绿野仙踪数据,fast-graphrag 的成本为 0.08 美元,而 graphrag 的成本为 0.48 美元——成本节省 6 倍,并且随着数据量和插入次数的增加,节省的成本会进一步提高。

Features

特性 (Features)
  • Interpretable and Debuggable Knowledge: Graphs offer a human-navigable view of knowledge that can be queried, visualized, and updated.
  • 可解释和可调试的知识:图提供了一种人类可导航的知识视图,可以查询、可视化和更新。
  • Fast, Low-cost, and Efficient: Designed to run at scale without heavy resource or cost requirements.
  • 快速、低成本和高效:旨在大规模运行,而无需大量的资源或成本要求。
  • Dynamic Data: Automatically generate and refine graphs to best fit your domain and ontology needs.
  • 动态数据:自动生成和改进图,以最适合您的领域和本体需求。(ontology needs.)
  • Incremental Updates: Supports real-time updates as your data evolves.
  • 增量更新:支持数据演变时的实时更新。
  • Intelligent Exploration: Leverages PageRank-based graph exploration for enhanced accuracy and dependability.
  • 智能探索:利用基于 PageRank 的图探索来提高准确性和可靠性。
  • Asynchronous & Typed: Fully asynchronous, with complete type support for robust and predictable workflows.
  • 异步和类型化:完全异步,具有完整的类型支持,可实现健壮且可预测的工作流程。

Fast GraphRAG is built to fit seamlessly into your retrieval pipeline, giving you the power of advanced RAG, without the overhead of building and designing agentic workflows.

Fast GraphRAG 的构建旨在无缝地融入您的检索管道,让您拥有高级 RAG 的强大功能,而无需构建和设计代理工作流程的开销。(advanced RAG, agentic workflows.)

Install

安装 (Install)

Install from source (recommended for best performance)

从源代码安装(推荐以获得最佳性能)
# clone this repo first
cd fast_graphrag
poetry install

Install from PyPi (recommended for stability)

从 PyPi 安装(推荐以获得稳定性)
pip install fast-graphrag

Quickstart

快速入门 (Quickstart)

Set the OpenAI API key in the environment:

在环境中设置 OpenAI API 密钥:
export OPENAI_API_KEY="sk-..."

Download a copy of A Christmas Carol by Charles Dickens:

下载查尔斯·狄更斯的小说《圣诞颂歌》的副本:
curl https://raw.githubusercontent.com/circlemind-ai/fast-graphrag/refs/heads/main/mock_data.txt > ./book.txt

Optional: Set the limit for concurrent requests to the LLM (i.e., to control the number of tasks processed simultaneously by the LLM, this is helpful when running local models)

可选:设置对 LLM 的并发请求的限制(即,控制 LLM 同时处理的任务数,这在运行本地模型时很有用)
export CONCURRENT_TASK_LIMIT=8

Use the Python snippet below:

使用下面的 Python 代码段:
from fast_graphrag import GraphRAG

DOMAIN = "Analyze this story and identify the characters. Focus on how they interact with each other, the locations they explore, and their relationships."

EXAMPLE_QUERIES = [
    "What is the significance of Christmas Eve in A Christmas Carol?",
    "How does the setting of Victorian London contribute to the story's themes?",
    "Describe the chain of events that leads to Scrooge's transformation.",
    "How does Dickens use the different spirits (Past, Present, and Future) to guide Scrooge?",
    "Why does Dickens choose to divide the story into \"staves\" rather than chapters?"
]

ENTITY_TYPES = ["Character", "Animal", "Place", "Object", "Activity", "Event"]

grag = GraphRAG(
    working_dir="./book_example",
    domain=DOMAIN,
    example_queries="\n".join(EXAMPLE_QUERIES),
    entity_types=ENTITY_TYPES
)

with open("./book.txt") as f:
    grag.insert(f.read())

print(grag.query("Who is Scrooge?").response)

The next time you initialize fast-graphrag from the same working directory, it will retain all the knowledge automatically.

下次您从同一个工作目录初始化 fast-graphrag 时,它将自动保留所有知识。

Examples

示例 (Examples)

Please refer to the examples folder for a list of tutorials on common use cases of the library:

请参阅 examples 文件夹,获取有关该库常见用例的教程列表:
  • custom_llm.py: a brief example on how to configure fast-graphrag to run with different OpenAI API compatible language models and embedders;
  • custom_llm.py:一个简短的示例,说明如何配置 fast-graphrag 以使用不同的 OpenAI API 兼容的语言模型和嵌入器运行;(language models and embedders;)
  • checkpointing.ipynb: a tutorial on how to use checkpoints to avoid irreversible data corruption;
  • checkpointing.ipynb:一个关于如何使用检查点以避免不可逆转的数据损坏的教程;(checkpoints)
  • query_parameters.ipynb: a tutorial on how to use the different query parameters. In particular, it shows how to include references to the used information in the provided answer (using the with_references=True parameter).
  • query_parameters.ipynb:一个关于如何使用不同的查询参数的教程。 特别是,它展示了如何将对所用信息的引用包含在提供的答案中(使用 with_references=True 参数)。

Philosophy

理念 (Philosophy)

Our mission is to increase the number of successful GenAI applications in the world. To do that, we build memory and data tools that enable LLM apps to leverage highly specialized retrieval pipelines without the complexity of setting up and maintaining agentic workflows.

我们的使命是增加世界上成功的 GenAI 应用程序的数量。 为此,我们构建内存和数据工具,使 LLM 应用程序能够利用高度专业的检索管道,而无需设置和维护代理工作流程的复杂性。(LLM, agentic workflows.)

Fast GraphRAG currently exploit the personalized pagerank algorithm to explore the graph and find the most relevant pieces of information to answer your query. For an overview on why this works, you can check out the HippoRAG paper here.

Fast GraphRAG 目前利用个性化的 pagerank 算法来探索图,并找到最相关的信息来回答您的查询。 有关为什么会这样工作的概述,您可以在此处查看 HippoRAG 论文。(pagerank algorithm)

Open-source or Managed Service

开源或托管服务 (Open-source or Managed Service)

This repo is under the MIT License. See LICENSE.txt for more information.

此 repo 采用 MIT 许可证。 有关更多信息,请参见 LICENSE.txt。

The fastest and most reliable way to get started with Fast GraphRAG is using our managed service. Your first 100 requests are free every month, after which you pay based on usage.

开始使用 Fast GraphRAG 最快和最可靠的方法是使用我们的托管服务。 您每月的前 100 个请求是免费的,之后您根据使用情况付费。

circlemind fast-graphrag demo

To learn more about our managed service, book a demo or see our docs.

要了解有关我们的托管服务的更多信息,请预约演示或查看我们的文档。