Home

Awesome

TempCaps: A Capsule Network-based Embedding Model for Temporal Knowledge Graph Completion

How to Cite Our Work

@inproceedings{TempCaps,
    title = "TempCaps: A Capsule Network-based Embedding Model for Temporal Knowledge Graph Completion",
    author = "Fu, Guirong  and
      Meng, Zhao  and
      Han, Zhen  and
      Ding, Zifeng  and
      Ma, Yunpu  and
      Schubert, Matthias and
      Tresp, Volker and
      Wattenhofer, Roger",
    booktitle = "Proceedings of the 6th Workshop on Structured Prediction for NLP (SPNLP@ACL 2022)",
    year = "2022",
    publisher = "Association for Computational Linguistics"
}

Installation

  1. create a conda environment:
conda create -n tkg python=3.6 anaconda
  1. run
source activate tkg
pip install -r requirements.txt

How to use?

  1. To train the model run the following command.
source activate tkg
python main.py \
  --config_path "configs/dyrmlp.yml" \
  --data_dir "data/completion/" \
  --dataset "icews14" \
  --task "completion" \
  --max_time_range 3 \
  --do_test True \
  --batch_size 300 \
  --overwrite True \
  --resume_train False \
  --max_epochs 240 \
  --save_steps 30 \
  --eval_steps 60 \
  --neg_ratio 0 \
  --test_size 256 \
  --from_pretrained False \
  --fix_pretrained False \
  --verbose False \
  --save_eval True \
  --checkpoint "DyRMLP_2305-1921_240_icews14.pth"

important parameters:

  1. To directly evalute the model run the following command
source activate tkg
python main.py \
  --config_path "configs/dyrmlp.yml" \
  --data_dir "data/completion/" \
  --task "completion" \
  --dataset "gdelt" \
  --checkpoint "DyRMLP_0206-2144_14_gdelt.pth" \
  --do_train False \
  --do_test True \
  --max_time_range 3 \
  --overwrite False \
  --test_size 256 \
  --save_eval True
  1. To reproduce the results for ICEWS14, ICEWS05-15, GDELT, run the following command:
source activate tkg
python main.py \
  --config_path "configs/dyrmlp.yml" \
  --data_dir "data/completion/" \
  --dataset "icews14" \
  --task "completion" \
  --max_time_range 3 \
  --do_test True \
  --batch_size 300 \
  --overwrite False \
  --resume_train False \
  --max_epochs 240 \
  --save_steps 240 \
  --eval_steps 240 \
  --neg_ratio 0 \
  --test_size 256
source activate tkg
python main.py \
  --config_path "configs/dyrmlp.yml" \
  --data_dir "data/completion/" \
  --dataset "icews05-15" \
  --task "completion" \
  --max_time_range 3 \
  --do_test True \
  --batch_size 300 \
  --overwrite False \
  --resume_train False \
  --max_epochs 200 \
  --save_steps 200 \
  --eval_steps 200 \
  --neg_ratio 0
source activate tkg
python main.py \
  --config_path "configs/dyrmlp.yml" \
  --data_dir "data/completion/" \
  --dataset "gdelt" \
  --task "completion" \
  --max_time_range 3 \
  --do_test True \
  --batch_size 300 \
  --overwrite False \
  --resume_train False \
  --max_epochs 5 \
  --save_steps 5 \
  --eval_steps 5 \
  --neg_ratio 0
  1. if you want to do experiment using other datasets, save the corresponding dataset files under specific data_dir and change the parameter dataset to the folder name you have saved. Format requirments of dataset files are in the Section Structures.

Structures