Code for One-shot Relational Learning for Knowledge Graphs
Switch branches/tags
Nothing to show
Clone or download
Permalink
Failed to load latest commit information.
imgs add img Sep 23, 2018
.gitignore init release Sep 23, 2018
LICENSE Create LICENSE Oct 16, 2018
README.md bib and training Oct 16, 2018
args.py init release Sep 23, 2018
data.py init release Sep 23, 2018
data_loader.py init release Sep 23, 2018
grapher.py init release Sep 23, 2018
matcher.py init release Sep 23, 2018
modules.py init release Sep 23, 2018
pre_embed.py init release Sep 23, 2018
tmp.py init release Sep 23, 2018
trainer.py init release Sep 23, 2018

README.md

One-Shot-Knowledge-Graph-Reasoning

PyTorch implementation of the One-Shot relational learning model described in our EMNLP 2018 paper One-Shot Relational Learning for Knowledge Graphs. In this work, we attempt to automatically infer new facts about a particular relation given only one training example. For instance, given the fact the "the Arlanda Airport is located in city Stochholm", the algorithm proposed in this papers tries to automatically infer that "the Haneda Airport is located in Tokyo" by utilizing the knowledge graph information about the involved entities (i.e. the Arlanda Airport, Stochholm, the Haneda Airport and Tokyo).

Method illustration

The main idea of this model is a matching network that encodes the one-hop neighbors of the involved entities, as defined in matcher.py.

Steps to run the experiments

Requirements

  • Python 3.6.5
  • PyTorch 0.4.1
  • tensorboardX
  • tqdm

Datasets

Download datasets Wiki-One or NELL-One

Pre-trained embeddings

Training

  • With random initialized embeddings: CUDA_VISIBLE_DEVICES=0 python trainer.py --max_neighbor 50 --fine_tune
  • With pretrained embeddings: CUDA_VISIBLE_DEVICES=0 python trainer.py --max_neighbor 50 --fine_tune --embed_model ComplEx

Visualization

tensorboard --logdir logs

Reference

@article{xiong2018one,
  title={One-Shot Relational Learning for Knowledge Graphs},
  author={Xiong, Wenhan and Yu, Mo and Chang, Shiyu and Guo, Xiaoxiao and Wang, William Yang},
  journal={arXiv preprint arXiv:1808.09040},
  year={2018}
}