GraphRAGZen
GraphRAGZen is a functional, common sense, library for developing GraphRAG pipelines.
A big thank you to the team at microsoft that created GraphRAG, which is the foundation for this project
Note
This project is in Beta and under active development.
Motivation
If you are not familiar with Graph RAG yet, I found this to be a good write-up
GraphRAG from Microsoft makes it easy to get started with automated Graph RAG.
Sadly, the codebase is hard to read, difficult to adapt, and dataflow in the pipelines near impossible to follow.
The work done by the GraphRAG team shouldn’t be in vain, but should allow for developers to create GraphRAG applications that are maintainable, extendable and intuitive.
And so GraphRAGZen was born; the logic given by GraphRAG in a functional, common sense library…
But that’s just another Graph RAG library, right?
It’s early days for GraphRAG technology, and there’s no standard implementation method accepted at large. This shows that there’s still a lack of high quality, easy to implement solutions in the OSS space.
From experience I found that most libraries available either provide a limited set of abilities with the bulk hiding behind convoluted code (i.e. GraphRAG) or are unintuitive and rely heavily on extended documentation.
This should be easily mitigated by writing a functional library. That is, the python function is king, and the functions are named and located intuitively.
When that is established we have a toolbox that can be used as seen fit by developers. It is modular, extendable, maintainable and intuitive.
Getting Started
Installation
pip install graphragzen
CLI
GraphRAGZen is made with developers in mind; it’s modularity allows integration with any backend and parts of the library to be used independently as needed. Nevertheless, if you just want to create a knowledge graph of your documents and query them, there is a CLI to do that.
Create a graph from your documents
python -m graphragzen.CLI.make_graph --documents_folder "path/to/folder/with/text/files" --project_folder "graphtest"
Query with context from the graph
python -m graphragzen.CLI.query --project_folder "graphtest"
Using GraphRAGZen as a library
The following examples are rather intuitive and should get you started (click on source)
Create prompts for extracting graphs that are specific to the domain of your documents:
graphragzen.examples.autotune_custom_prompts.create_custom_prompts()
Create a graph, graph clusters and text embedding vectors:
graphragzen.examples.generate_entity_graph.entity_graph_pipeline()
Query the graph:
graphragzen.examples.query.question()
LLM
GraphRAGZen relies on an LLM to create a graph from documents.
Two methods are supported to interact with an LLM:
With an LLM running on a server through an openAI API compatible endpoint.
This server can be remote or deployed locally depending on your own preference.
By loading the model locally in-memory.
Loading a model in-memory uses llama-cpp-python and unlikely uses your GPU unless configured well. Thus using in-memory is good for development and testing, but for production deployment it is recommended to communicate with an LLM that is properly set-up on a server.
For more information see LLM interaction