Skip to main content

A simple, easy-to-hack GraphRAG implementation

Project description

nano-GraphRAG

A simple, easy-to-hack GraphRAG implementation

😭 GraphRAG is good and powerful, but the official implementation is not very "easy" to read or hack.

😊 This project aims to provide a simpler implementation, while retaining the core functionality.

👌 nano-graphrag is about 1000-lines of python, but performs the same as the original implementation.

Install

Install from PyPi

pip install nano-graphrag

Install from source

# clone this repo first
cd nano-graphrag
pip install -e .

Quick Start

download a copy of A Christmas Carol by Charles Dickens:

curl https://www.gutenberg.org/cache/epub/24022/pg24022.txt > ./book.txt

Use the below python snippet:

from nano_graphrag import GraphRAG

graph_func = GraphRAG()

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

print(graph_func.query("What are the top themes in this story?"))

Save the graph for the next time:

graph_func.save("path/to/dir")
# -------- next time ---------
graph_func = GraphRAG.from_dir("path/to/dir")

For each method NAME(...) , there is a corresponding async method aNAME(...)

await graph_func.ainsert(...)
await graph_func.aquery(...)
...

Benchmark

TODO

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nano_graphrag-0.0.1.tar.gz (11.4 kB view hashes)

Uploaded Source

Built Distribution

nano_graphrag-0.0.1-py3-none-any.whl (11.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page