Code implementation for DyG-RAG: Dynamic Graph Retrieval-Augmented Generation with Event-Centric Reasoning.
Python
58
22 commits
updated Aug 28, 2025
DyG-RAG is the first event-centric dynamic graph retrieval-augmented generation framework specifically designed to capture, organize, and reason over temporal knowledge embedded within unstructured text data. By explicitly modeling the temporal dynamics of events as graph-structured representations, DyG-RAG facilitates enhanced temporal reasoning, yielding substantial accuracy improvement in temporal QA task.
cd DyG-RAG
conda create -n dygrag python=3.10
conda activate dygrag
# Install dependencies
pip install -r requirements.txt
Set your OpenAI API key:
# Option 1: API-Environment variable
export OPENAI_API_KEY="your_api_key_here"
# Download required models
cd models
python download.py
Downloaded Models:
The script downloads two essential models:
Cross-Encoder Model:
cross-encoder/ms-marco-TinyBERT-L-2-v2./models/cross-encoder_ms-marco-TinyBERT-L-2-v2/NER Model:
dslim/bert-base-NER./models/dslim_bert_base_ner/If you want to use local models instead of OpenAI, you can set up environment variables for the local embedding and LLM configuration (using BGE and Qwen as examples):
# Local BGE embedding model path (example: BGE-M3)
export LOCAL_BGE_PATH="/path/to/your/bge-m3"
# VLLM API service URL (example: local VLLM server)
export VLLM_BASE_URL="http://127.0.0.1:8000/v1"
# Model name for LLM (example: Qwen model)
export QWEN_BEST="qwen-14b"
# Basic usage with OpenAI
cd examples
python openai_all.py
# Using local models
python local_BGE_local_LLM.py
DyG-RAG/
├── requirements.txt # Dependencies
├── examples/ # Usage examples
├── graphrag/ # src codes of DyG-RAG
├── demo/ # TimeQA dataset example
├── datasets/ # three types of temporal QA datasets
└── models/ # Downloaded models
This project is built upon the excellent work of nano-graphrag by Gustavo Ye. We extend our sincere gratitude to the original author for providing a simple, easy-to-hack GraphRAG implementation that serves as the foundation for our DyG-RAG system.
Code implementation for DyG-RAG: Dynamic Graph Retrieval-Augmented Generation with Event-Centric Reasoning.
Python
58
22 commits
updated Aug 28, 2025
DyG-RAG is the first event-centric dynamic graph retrieval-augmented generation framework specifically designed to capture, organize, and reason over temporal knowledge embedded within unstructured text data. By explicitly modeling the temporal dynamics of events as graph-structured representations, DyG-RAG facilitates enhanced temporal reasoning, yielding substantial accuracy improvement in temporal QA task.
cd DyG-RAG
conda create -n dygrag python=3.10
conda activate dygrag
# Install dependencies
pip install -r requirements.txt
Set your OpenAI API key:
# Option 1: API-Environment variable
export OPENAI_API_KEY="your_api_key_here"
# Download required models
cd models
python download.py
Downloaded Models:
The script downloads two essential models:
Cross-Encoder Model:
cross-encoder/ms-marco-TinyBERT-L-2-v2./models/cross-encoder_ms-marco-TinyBERT-L-2-v2/NER Model:
dslim/bert-base-NER./models/dslim_bert_base_ner/If you want to use local models instead of OpenAI, you can set up environment variables for the local embedding and LLM configuration (using BGE and Qwen as examples):
# Local BGE embedding model path (example: BGE-M3)
export LOCAL_BGE_PATH="/path/to/your/bge-m3"
# VLLM API service URL (example: local VLLM server)
export VLLM_BASE_URL="http://127.0.0.1:8000/v1"
# Model name for LLM (example: Qwen model)
export QWEN_BEST="qwen-14b"
# Basic usage with OpenAI
cd examples
python openai_all.py
# Using local models
python local_BGE_local_LLM.py
DyG-RAG/
├── requirements.txt # Dependencies
├── examples/ # Usage examples
├── graphrag/ # src codes of DyG-RAG
├── demo/ # TimeQA dataset example
├── datasets/ # three types of temporal QA datasets
└── models/ # Downloaded models
This project is built upon the excellent work of nano-graphrag by Gustavo Ye. We extend our sincere gratitude to the original author for providing a simple, easy-to-hack GraphRAG implementation that serves as the foundation for our DyG-RAG system.