This repository is the PyTorch implementation of PathCon (arXiv):
Entity Context and Relational Paths forKnowledge Graph Completion
Hongwei Wang, Hongyu Ren, Jure Leskovec
arXiv Preprint, 2020
Please find the Tensorflow version here.
PathCon considers relational context and relational paths of (head, tail) pair in knowledge graphs for link prediction. PathCon achieves substantial gains over state-of-the-art baselines. Below is the result of Hit@1 on the test set of FB15K, FB15K-237, WN18, WN18RR, NELL995, and DDB14 datasets for relation prediction task:
Method | FB15K | FB15K-237 | WN18 | WN18RR | NELL995 | DDB14 |
---|---|---|---|---|---|---|
TransE | 94.0 | 94.6 | 95.5 | 66.9 | 78.1 | 94.8 |
RotatE | 96.7 | 95.1 | 97.9 | 73.5 | 69.1 | 93.4 |
QuatE | 97.2 | 95.8 | 97.5 | 76.7 | 70.6 | 92.2 |
DRUM | 94.5 | 90.5 | 95.6 | 77.8 | 64.0 | 93.0 |
PathCon | 97.4 (+/-0.2) | 96.4 (+/-0.1) | 98.8 (+/-0.1) | 95.4 (+/-0.2) | 84.4 (+/-0.4) | 96.6 (+/-0.1) |
For more results, please refer to the original paper.
data/
FB15k/
FB15k-237/
wn18/
wn18rr/
NELL995/
DDB14/
src/
: implementation of PathCon.Note: We provide a cache/
folder for each dataset, which caches the pre-computed relational paths for this dataset.
This folder is not required for running the code because relational paths will be counted (and cached) if no corresponding cache file is found.
If you are going to run FB15K-237 with max_path_len=3, please first download and unzip paths_3.zip
from here and put all unzipped files under FB15k-237/cache/
(the original files cannot be uploaded to GitHub due to the limitation on file size).
Again, this is not required but highly recommended because counting length-3 paths for FB15K-237 will be time-consuming.
$ python main.py --cuda
Note: The default dataset is set as WN18RR.
Hyper-parameter settings for other datasets are provided in main.py
.
The code has been tested running under Python 3.6.5, with the following packages installed (along with their dependencies):