This repository introduces EA_RAG, a novel framework for entity alignment in knowledge graphs (KGs) using Retrieval-Augmented Generation (RAG) with Large Language Models (LLMs). The framework dynamically integrates retrieval mechanisms with generative models to align entities across multilingual and multi-modal KGs.
The primary contribution of this project is the implementation of RAG-based alignment methods, evaluated against traditional embedding-based approaches provided by the EAkit framework.
- RAG-Based Alignment: A novel entity alignment approach leveraging generative capabilities of LLMs.
- Dynamic Retrieval: Incorporates external knowledge during the alignment process for improved accuracy.
- Evaluation Using EAkit: Benchmarked against state-of-the-art embedding-based methods such as GCN-Align, MTransE, and BootEA.
- Cross-Lingual Matching: Optimized for datasets like DBP15K, supporting multilingual knowledge graphs.
- Scalable Architecture: Uses Pinecone for efficient vector storage and retrieval.
- Python: 3.11
- Conda: Miniconda or Anaconda (Download Miniconda)
- Git: Installed and configured (Download Git)
- Pinecone: API for vector embedding management (Pinecone Documentation)
Clone the repository with submodules:
git clone --recurse-submodules https://github.com/DariMe20/Entity-Alignment-KG
cd Entity-Alignment-KG-
Create and activate the environment:
conda create --name ea_rag python=3.11 -y conda activate ea_rag
-
Verify the Python version:
python --version # Should output 3.11.x
Install required packages using pip:
pip install -r requirements.txtCreate a .env file with the following details:
OPENAI_API_KEY01=your_openai_key
OPENAI_API_KEY02=your_openai_key
OPENAI_API_KEY03=your_openai_key
OPENAI_API_KEY04=your_openai_key
OPENAI_API_KEY05=your_openai_key
PINECONE_API_KEY=your_pinecone_key
- Download the DBP15K dataset from Hugging Face.
- Extract and rename the folder to
fr_enin the repository directory.
The implementation and usage of the EA_RAG framework are detailed in the Jupyter Notebook ea-rag/main.ipynb. Follow the instructions in the notebook to:
- Embed knowledge graph entities using LLM-based text embedding models.
- Store and retrieve embeddings with Pinecone.
- Query and align entities using a combination of retrieval mechanisms and generative models.
Experiments were conducted on subsets of the DBP15K dataset (English-French), comparing the RAG-based alignment against ground truth. Below are the results:
| Dataset Size | Hits@1 | Processing Time |
|---|---|---|
| 150 Entities | 0.6667 | ~30 seconds |
| 1,500 Entities | 0.6421 | ~7 minutes |
| 15,000 Entities | 0.6465 | ~61 minutes |
The embedding-based methods implemented in EAkit were evaluated on the same DBP15K (English-French) dataset, focusing on Hits@1 accuracy. Below are the results for each method:
| Method | Hits@1 | Processing Time |
|---|---|---|
| BootEA | 0.5148 | ~12 hours |
| GCN-Align | 0.4303 | ~25 minutes |
| MTransE | 0.4073 | ~11 minutes |
To benchmark EA_RAG, we evaluated it against embedding-based methods provided by EAkit. Note that EAkit requires a separate environment setup:
- Create a Conda environment for EAkit:
conda create --name eakit python=3.7 -y conda activate eakit
- Install dependencies:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu pip install torch-geometric torch-scatter torch-sparse torch-cluster torch-spline-conv -f https://data.pyg.org/whl/torch-2.0.0+cpu.html pip install numpy scipy scikit-learn tensorboard
-
Activate the EAkit environment:
conda activate eakit
-
Navigate to the examples folder:
cd EAkit/examples -
Run a predefined alignment script (e.g., GCN-Align):
./run_GCN-Align.sh
-
Alternatively, execute directly with custom parameters:
python ../run.py --data_dir "../data/DBP15K/zh_en" --encoder "GCN-Align"
-
Monitor metrics using TensorBoard:
./Tensorboard.sh
Open
http://localhost:6006in a browser.
This project is licensed under the MIT License. See the LICENSE file for details.
If you use this framework, please cite the relevant works:
@inproceedings{bara2025retrieval,
author = {Davide Mario Ricardo Bara and
Daria Maria Meseșan and
Gheorghe Cosmin Silaghi},
title = {Retrieval-Augmented Generation for Entity Alignment in Knowledge Graphs: an Incipient Experiment},
booktitle = {Advanced Information Systems Engineering Workshops, CAiSE 2025 International Workshops},
year = {2025},
publisher = {Springer},
series = {Lecture Notes in Computer Science},
note = {To appear}
}