Home

Awesome

Type-aware Embeddings for Multi-Hop Reasoning over Knowledge Graphs

This repo provides the source code & data of our paper: Type-aware Embeddings for Multi-Hop Reasoning over Knowledge Graphs (IJCAI 2022).

Dependencies

Running the code

Dataset

Models

Training Model

Generalization

export DATA_PATH=../data/FB15k-237-betae
export SAVE_PATH=../logs/FB15k-237/gqe_temp
export LOG_PATH=../logs/FB15k-237/gqe_temp.out
export MODEL=temp
export FAITHFUL=no_faithful

export MAX_STEPS=450000
export VALID_STEPS=10000
export SAVE_STEPS=10000
export ENT_TYPE_NEIGHBOR=32
export REL_TYPE_NEIGHBOR=64

CUDA_VISIBLE_DEVICES=0 nohup python -u ../main.py --cuda --do_train --do_valid --do_test \
  --data_path $DATA_PATH --save_path $SAVE_PATH -n 128 -b 512 -d 800 -g 24 \
  -lr 0.0001 --max_steps $MAX_STEPS --valid_steps $VALID_STEPS --save_checkpoint_steps $SAVE_STEPS \
  --cpu_num 1 --geo vec --test_batch_size 16 --tasks "1p.2p.3p.2i.3i.ip.pi.2u.up" --print_on_screen \
  --faithful $FAITHFUL --model_mode $MODEL --neighbor_ent_type_samples $ENT_TYPE_NEIGHBOR --neighbor_rel_type_samples $REL_TYPE_NEIGHBOR \
  > $LOG_PATH 2>&1 &

Deductive

export DATA_PATH=../data/FB15k-237-betae
export SAVE_PATH=../logs/FB15k-237/gqe_faithful_temp
export LOG_PATH=../logs/FB15k-237/gqe_faithful_temp.out
export MODEL=temp
export FAITHFUL=faithful

export MAX_STEPS=450000
export VALID_STEPS=10000
export SAVE_STEPS=10000
export ENT_TYPE_NEIGHBOR=32
export REL_TYPE_NEIGHBOR=64

CUDA_VISIBLE_DEVICES=0 nohup python -u ../main.py --cuda --do_train --do_valid --do_test \
  --data_path $DATA_PATH --save_path $SAVE_PATH -n 128 -b 512 -d 800 -g 24 \
  -lr 0.0001 --max_steps $MAX_STEPS --valid_steps $VALID_STEPS --save_checkpoint_steps $SAVE_STEPS \
  --cpu_num 1 --geo vec --test_batch_size 16 --tasks "1p.2p.3p.2i.3i.ip.pi.2u.up" --print_on_screen \
  --faithful $FAITHFUL --model_mode $MODEL --neighbor_ent_type_samples $ENT_TYPE_NEIGHBOR --neighbor_rel_type_samples $REL_TYPE_NEIGHBOR \
  > $LOG_PATH 2>&1 &

Citation

If you find this code useful, please consider citing the following paper.

@article{DBLP:journals/corr/abs-2205-00782,
  author    = {Zhiwei Hu and Víctor Gutiérrez-Basulto and Zhiliang Xiang and Xiaoli Li and Ru Li and Jeff Z. Pan},
  title     = {Type-aware Embeddings for Multi-Hop Reasoning over Knowledge Graphs},
  journal   = {CoRR},
  volume    = {abs/2205.00782},
  year      = {2022},
  url       = {https://doi.org/10.48550/arXiv.2205.00782},
  doi       = {10.48550/arXiv.2205.00782},
  eprint    = {2205.00782},
}

Acknowledgement

We refer to the code of KGReasoning. Thanks for their contributions.