- Python 3.11
- Conda (recommended)
- Clone the repository:
git clone https://github.com/RAKG/RAKG.git
cd RAKG- Create and activate a conda environment:
conda create -n RAKG python=3.11
conda activate RAKG- Install dependencies:
pip install -r requirements.txtEdit src/config.py to configure your model provider settings:
- For local Ollama: Set
base_urltohttp://localhost:11434/v1/ - For server-based Ollama: Set
base_urltohttp://your_server_ip
Default Ollama model configurations:
- Main model: Qwen2.5-72B, requires good instruction following
- Similarity check model: Qwen2-7B, using smaller model for faster processing
- embedding model: BGE-M3
- Set your OpenAI API key in
OPENAI_API_KEY - Configure model selection:
- Main model: Qwen2.5-72B-Instruct
- Similarity check model: Qwen2.5-14B-Instruct
- Embedding model: BGE-M3
To switch between providers, set USE_OPENAI = True for OpenAI or False for Ollama.
To process text input:
cd examples
python RAKG_example.py --input "your input text" --output result/kg.json --topic "your_topic" --is-textTo process document input:
python RAKG_example.py --input data/MINE.json --output result/kg.jsonTo reproduce the results from the paper:
cd src/construct
python RAKG.pycd src/eval/llm_evalFor evaluation purposes, we recommend using the DeepEval platform. Please refer to the DeepEval documentation for setup and usage instructions.
cd src/eval/MINE_eval
python evaluate_MINE_RAKG.pycd src/eval/ideal_kg_eval
python kg_eval.pyWe welcome contributions! Please read our contributing guidelines before submitting pull requests.
This repo benefits from:
Thanks for these wonderful works.
For any questions or feedback, please:
- Open an issue in the GitHub repository
- Reach out to us at 2212855@mail.nankai.edu.cn
If you find our paper and codes useful, please kindly cite us via:
@misc{zhang2025rakgdocumentlevelretrievalaugmentedknowledge,
title={RAKG:Document-level Retrieval Augmented Knowledge Graph Construction},
author={Hairong Zhang and Jiaheng Si and Guohang Yan and Boyuan Qi and Pinlong Cai and Song Mao and Ding Wang and Botian Shi},
year={2025},
eprint={2504.09823},
archivePrefix={arXiv},
primaryClass={cs.IR},
url={https://arxiv.org/abs/2504.09823},
}