/CIDF

Causal Inference-based Debiasing Framework for Knowledge Graph Completion

Primary LanguagePython

Causal Inference Based Debiasing Framework for Knowledge Graph Completion

Code for Causal Inference Based Debiasing Framework for Knowledge Graph Completion

In this paper, we conduct a comprehensive analysis of these biases to determine their extent of impact. To mitigate these biases, we propose a debiasing framework called Causal Inference-based Debiasing Framework for KGC (CIDF) by formulating a causal graph and utilizing it for causal analysis of KGC tasks.

In this project, we employ CIDF on SimKGC.

Requirements

python=3.7
torch=1.11.0+cu113
transformers=4.27.1
wandb

All experiments are run with 4 V100(32GB) GPUs.

Download Datasets

For datasets WN18RR and FB25k-127, SimKGC provides their resources for downloading.

For datasets Wikidata5M, it can be downloaded as following:

bash ./scripts/download_wikidata5m.sh

The directory structure is as follows:

data
|- FB15k237
|- WN18RR
|- wikidata5m

Preprocess Datasets

After downloading the datasets, use the following bash commands to preprocess them.

bash scripts/preprocess.sh WN18RR

bash scripts/preprocess.sh FB15k237

bash scripts/preprocess.sh wiki5m_trans

bash scripts/preprocess.sh wiki5m_ind

Train and Evaluate

You can use the following bash commands to train and evaluate CIDF

OUTPUT_DIR=<model_saved_path> bash <script_path> <logger_name_of_wandb>

OUTPUT_DIR=./checkpoint/wn18rr/ bash scripts/train_wn.sh wn

OUTPUT_DIR=./checkpoint/fb15k237/ bash scripts/train_fb.sh fb

OUTPUT_DIR=./checkpoint/wikiT/ bash scripts/train_wiki_trans.sh wiki5m_trans

OUTPUT_DIR=./checkpoint/wikiI/ bash scripts/train_wiki_ind.sh wiki5m_ind

Evaluate Only

train_args.bin will be created in model_saved_path when training is finished.

You can reload the training set and evaluate the model as follow:

python evaluate.py -apath <model_saved_path>/train_args.bin

Citation

If you use our code in your research, please cite our work:

@inproceedings{10.1007/978-3-031-47240-4_18,
author = {Ren, Lin and Liu, Yongbin and Ouyang, Chunping},
title = {Causal Inference-Based Debiasing Framework for&nbsp;Knowledge Graph Completion},
year = {2023},
isbn = {978-3-031-47239-8},
publisher = {Springer-Verlag},
address = {Berlin, Heidelberg},
url = {https://doi.org/10.1007/978-3-031-47240-4_18},
doi = {10.1007/978-3-031-47240-4_18},
booktitle = {The Semantic Web – ISWC 2023: 22nd International Semantic Web Conference, Athens, Greece, November 6–10, 2023, Proceedings, Part I},
pages = {328–347},
numpages = {20},
keywords = {Knowledge Graph Completion, Causal Inference, Link Prediction},
location = {Athens, Greece}
}