GraphRAG is a powerful tool that allows you to build knowledge-graph retrieval-augmented generation (RAG) systems using large language models (LLMs). However, the original GraphRAG is designed for OpenAI models only. This project contains a modified version of Microsoft's GraphRAG that supports building knowledge graph retrieval-augmented generation (RAG) systems using open-source models like Qwen. This project integrates GraphRAG with Open-webUI, providing support for customized models deployed through Ollama via pipelines.
Ensure you have the following installed:
- Open-webUI: Web interface for model management and interaction
- Ollama: For model deployment
- Python 3.11+: Project requires Python 3.11 or higher
- Download qwen2-7b-instruct-q5_k_m.gguf from HuggingFace
- Update the model path in
Modelfile-Qwen2-instruct
- Install using Ollama:
ollama install --model-file Modelfiles/Modelfile-Qwen2-instruct
This is a modified version of GraphRAG that supports non-OpenAI models:
pip install -e ./Graphrag/graphrag
GraphRAG requires an embedding model. Install the embedding model in Ollama :
ollama pull nomic-embed-text
In a new terminal:
cd Graphrag/BuildGR
# Prepare input data
cp data/*.txt input
# Initialize graphrag index
python -m graphrag.index --init --root .
# Use example configuration
cp settings.yaml-example settings.yaml
# Build knowledge graph. This will take a while:
python -m graphrag.index --root .
Use the Open-webUI pipeline, copy and rename the env-example file to the Open-webUI pipelines directory. Customize the .env file with your own API keys.
cp ./pipelines/.env-example <openwebui-pipelines-directory>/.env
Then copy 'graphrag_globalsearch_pipeline.py' and 'graphrag_localsearch_pipeline.py' to the pipelines folder under Open-webUI pipelines directory.
cp ./pipelines/pipelines/graphrag_globalsearch_pipeline.py <openwebui-pipelines-directory>/pipelines/
cp ./pipelines/pipelines/graphrag_localsearch_pipeline.py <openwebui-pipelines-directory>/pipelines/
When setting up pipelines, the OpenAI API in the admin settings should be configured by connecting to port '9099'.
The following is an example of the connection for Open-webUI running in the Docker container:
Then restart pipelines in the Open-webUI pipelines directory by running:
cd <openwebui-pipelines-directory>
sh ./start.sh
Once all set, you can select 'GraphRag GlobalSearch Pipeline' for a global search or 'GraphRag LocalSearch Pipeline' for localized searches.
Additional features and improvements are under development. Stay tuned for future updates!
Created by Chuck Zuo, Ph.D. - Let's make TAMU-AI great together!