8000 GitHub - LMMApplication/RAKG
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

LMMApplication/RAKG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAKG: Document-level Retrieval Augmented Knowledge Graph Construction

If you find our project useful, please give us a star ⭐ on GitHub for the latest updates.

💡 Overview

RAKG is a knowledge graph construction framework that leverages large language models for automated knowledge graph generation. The framework processes documents through sentence segmentation and vectorization, extracts preliminary entities, and performs entity disambiguation and vectorization. The processed entities undergo Corpus Retrospective Retrieval to obtain relevant texts and Graph Structure Retrieval to get related KG. Subsequently, LLM is employed to integrate the retrieved information for constructing relation networks, which are merged for each entity. Finally, the newly built knowledge graph is combined with the original one.

🔧 Installation

Prerequisites

  • Python 3.11
  • Conda (recommended)

Environment Setup

  1. Clone the repository:
git clone https://github.com/RAKG/RAKG.git
cd RAKG
  1. Create and activate a conda environment:
conda create -n RAKG python=3.11
conda activate RAKG
  1. Install dependencies:
pip install -r requirements.txt

🏃 Quick Start

Configuration

Model Provider Configuration

Edit src/config.py to configure your model provider settings:

Ollama Configuration
  • For local Ollama: Set base_url to http://localhost:11434/v1/
  • For server-based Ollama: Set base_url to http://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
OpenAI Configuration
  • 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.

Usage Examples

Text Input

To process text input:

cd examples
python RAKG_example.py --input "your input text" --output result/kg.json --topic "your_topic" --is-text

Document Input

To process document input:

python RAKG_example.py --input data/MINE.json --output result/kg.json

Reproducing Paper Results

To reproduce the results from the paper:

cd src/construct
python RAKG.py

📊 Evaluation

LLM Evaluation

cd src/eval/llm_eval

For evaluation purposes, we recommend using the DeepEval platform. Please refer to the DeepEval documentation for setup and usage instructions.

MINE Evaluation

cd src/eval/MINE_eval
python evaluate_MINE_RAKG.py

Ideal KG Evaluation

cd src/eval/ideal_kg_eval
python kg_eval.py

🤝 Contributing

We welcome contributions! Please read our contributing guidelines before submitting pull requests.

❤️ Acknowledgement

This repo benefits from:

Thanks for these wonderful works.

📞 Contact

For any questions or feedback, please:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
0