This repository provides a structured setup for configuring a Nebula graph database, building a knowledge graph, and integrating it with a Retrieval-Augmented Generation (RAG) model.
- Docker
- Python 3.9+
-
Clone the Repository
git clone ttps://github.com/h9-tect/RAG_with_Kg.git cd knowledge-graph-rag
-
Install Docker
Ensure Docker is installed and running on your machine. You can download Docker from here.
-
Run Nebula Container
Execute the following Docker commands to pull and run the Nebula container:
docker pull vesoft/nebula-graph:nightly docker run -d --name nebula-server vesoft/nebula-graph:nightly
-
Set Environment Variables
Adjust environment variables as needed in
config/nebula_config.py
. -
Install Python Dependencies
Install the required Python packages:
pip install -r requirements.txt
-
Setup Nebula Database
Run the following command to set up the Nebula database:
python database/setup_nebula.py
-
Run the Main Application
Run the main application to build the knowledge graph and query it:
python main.py
- main.py: The entry point of the application. It sets up the Nebula database, builds the knowledge graph, and performs queries.
- config/nebula_config.py: Contains the configuration for connecting to the Nebula database.
- database/setup_nebula.py: Sets up the Nebula database schema.
- kg_rag/query_kg_rag.py: Contains functions to load documents, build a knowledge graph, and query it. Also includes a custom retriever to combine results from vector and graph databases.
- requirements.txt: Lists the Python dependencies for the project.
- Dockerfile: Dockerfile to containerize the application.
This project is licensed under the MIT License.