Skip to content

Repository files navigation

🚀 Hypergraph RAG: Enhancing Query-Focused Summarization Through Overlapping Community

The structure of this code is based on nano-graphrag.

Install

Install from source (recommend)

# clone this repo first
cd HypergraphRAG
pip install -e .

Quick Start

Tip

Please set OpenAI API key in environment: export OPENAI_API_KEY="sk-...".

download a copy of A Christmas Carol by Charles Dickens:

curl https://raw.githubusercontent.com/gusye1234/nano-graphrag/main/tests/mock_data.txt > ./book.txt

Use the below python snippet:

from nano_hypergraphrag import HypergraphRAG, QueryParam

hypergraph_func = HypergraphRAG(working_dir="./dickens")

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

# Perform global graphrag search
print(hypergraph_func.query("What are the top themes in this story?"))

# Perform local graphrag search (I think is better and more scalable one)
print(hypergraph_func.query("What are the top themes in this story?", param=QueryParam(mode="local")))

Next time you initialize a HypergraphRAG from the same working_dir, it will reload all the contexts automatically.

About

No description, website, or topics provided.

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages