Git Product home page Git Product logo

jinheonbaek / gen Goto Github PK

View Code? Open in Web Editor NEW
56.0 2.0 11.0 123.46 MB

Official Code Repository for the paper "Learning to Extrapolate Knowledge: Transductive Few-shot Out-of-Graph Link Prediction" (NeurIPS 2020)

Home Page: https://arxiv.org/abs/2006.06648

Python 100.00%
meta-learning graph-neural-network few-shot-learning link-prediction graph-link-prediction graph-neural-networks knowledge-graph deep-learning

gen's Introduction

Learning to Extrapolate Knowledge:
Transductive Few-shot Out-of-Graph Link Prediction

Official Code Repository for the paper "Learning to Extrapolate Knowledge: Transductive Few-shot Out-of-Graph Link Prediction" (NeurIPS 2020) : https://arxiv.org/abs/2006.06648.

In this repository, we implement Graph Extrapolation Network (GEN) with both inductive and transductive schemes, proposed in our paper.

Abstract

Many practical graph problems, such as knowledge graph construction and drug-drug interaction prediction, require to handle multi-relational graphs. However, handling real-world multi-relational graphs with Graph Neural Networks (GNNs) is often challenging due to their evolving nature, where new entities (nodes) can emerge over time. Moreover, newly emerged entities often have few links, which makes the learning even more difficult. Motivated by this challenge, we introduce a realistic problem of few-shot out-of-graph link prediction, where we not only predict the links between the seen and unseen nodes as in a conventional out-of-knowledge link prediction but also between the unseen nodes, with only few edges per node. We tackle this problem with a novel transductive meta-learning framework which we refer to as Graph Extrapolation Networks (GEN). GEN meta-learns both the node embedding network for inductive inference (seen-to-unseen) and the link prediction network for transductive inference (unseen-to-unseen). For transductive link prediction, we further propose a stochastic embedding layer to model uncertainty in the link prediction between unseen entities. We validate our model on multiple benchmark datasets for knowledge graph completion and drug-drug interaction prediction. The results show that our model significantly outperforms relevant baselines for out-of-graph link prediction tasks.

Contribution of this work

  • We tackle a realistic problem setting of few-shot out-of-graph link prediction, aiming to perform link prediction not only between seen and unseen entities but also among unseen entities for multi-relational graphs that exhibit long-tail distributions, where each entity has only few triplets.
  • To tackle this problem, we propose a novel meta-learning framework, Graph Extrapolation Network (GEN), which meta-learns the node embeddings for unseen entities, to obtain low error on link prediction for both seen-to-unseen (inductive) and unseen-to-unseen (transductive) cases.
  • We validate GEN for few-shot out-of-graph link prediction tasks on five benchmark datasets for knowledge graph completion and drug-drug interaction prediction, on which it significantly outperforms relevant baselines, even when baseline models are re-trained with the unseen entities.

Dependencies

  • Python 3.7
  • PyTorch 1.4
  • PyTorch Geometric 1.4.3

Training

To train models in the paper, run following commands:

  • (GEN-KG) FB15k-237 - Inductive (I-GEN)
python trainer_induc.py --data FB15k-237 --gpu -1 --few 3 --pre-train --fine-tune --model InducGEN --pre-train-model DistMult --score-function DistMult --margin 1 --seed 42 --evaluate-every 500 --pre-train-emb-size 100 --negative-sample 32 --model-tail log --max-few 10
  • (GEN-KG) FB15k-237 - Transductive (T-GEN)
python trainer_trans.py --data FB15k-237 --gpu -1 --few 3 --pre-train --fine-tune --model TransGEN --pre-train-model DistMult --score-function DistMult --margin 1 --seed 42 --evaluate-every 500 --pre-train-emb-size 100 --negative-sample 32 --model-tail log --max-few 10
  • (GEN-DDI) DeepDDI - Inductive (I-GEN)
python trainer_induc.py --data DeepDDI --pre-train --fine-tune --pre-train-model MPNN --n-epochs 5000 --evaluate-every 100 --model InducGEN --seed 42 --gpu -1 --few 3 --bases 200
  • (GEN-DDI) DeepDDI - Transductive (T-GEN)
python trainer_trans.py --data DeepDDI --pre-train --fine-tune --pre-train-model MPNN --n-epochs 5000 --evaluate-every 100 --model TransGEN --seed 42 --gpu -1 --few 3 --bases 200

Evaluation

To evaluate models, run following commands:

  • (GEN-KG) FB15k-237 - Inductive (I-GEN)
python eval_induc.py --data FB15k-237 --gpu -1 --few 3 --pre-train --fine-tune --model InducGEN --pre-train-model DistMult --score-function DistMult --margin 1 --pre-train-emb-size 100 --negative-sample 32 --exp-name FB15k-237_Induc
  • (GEN-KG) FB15k-237 - Transductive (T-GEN)
python eval_trans.py --data FB15k-237 --gpu -1 --few 3 --pre-train --fine-tune --model TransGEN --pre-train-model DistMult --score-function DistMult --margin 1 --pre-train-emb-size 100 --negative-sample 32 --exp-name FB15k-237_Trans --mc-times 10
  • (GEN-DDI) DeepDDI - Inductive (I-GEN)
python eval_induc.py --data DeepDDI --gpu -1 --few 3 --pre-train --fine-tune --model InducGEN --pre-train-model MPNN --exp-name Deep-DDI_Induc --bases 200
  • (GEN-DDI) DeepDDI - Transductive (T-GEN)
python eval_trans.py --data DeepDDI --gpu -1 --few 3 --pre-train --fine-tune --model TransGEN --pre-train-model MPNN --exp-name Deep-DDI_Trans --bases 200 --mc-times 10

Pre-trained Models

You can see the pre-trained models in a Pretraining folder for each task (GEN-KG or GEN-DDI).

Results

We demonstrate our Graph Extrapolation Networks on two types of link prediction task: entity prediction for knowledge graph completion and relation prediction for drug-drug interaction prediction.

Our model achieves the following performances for 3-shot entity prediction on FB15k-237 dataset.

Model MRR Hits@1 Hits@3 Hits@10
I-GEN .367 .281 .407 .537
T-GEN .382 .289 .430 .565

Our model achieves the following performances for 3-shot relation prediction on DeepDDI dataset.

Model ROC PR Acc
I-GEN .946 .681 .807
T-GEN .954 .708 .815

Citation

If you found the provided code with our paper useful in your work, we kindly request that you cite our work.

@inproceedings{baek2020gen,
 author = {Baek, Jinheon and Lee, Dong Bok and Hwang, Sung Ju},
 booktitle = {Advances in Neural Information Processing Systems},
 editor = {H. Larochelle and M. Ranzato and R. Hadsell and M. F. Balcan and H. Lin},
 pages = {546--560},
 publisher = {Curran Associates, Inc.},
 title = {Learning to Extrapolate Knowledge: Transductive Few-shot Out-of-Graph Link Prediction},
 url = {https://proceedings.neurips.cc/paper/2020/file/0663a4ddceacb40b095eda264a85f15c-Paper.pdf},
 volume = {33},
 year = {2020}
}

gen's People

Contributors

jinheonbaek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gen's Issues

Split of the Unseen entities

Thank you for your excellent work!

Unseen entities are split into (meta-)train/val/test. In your code, i found that the triplets in self.meta_train_task_entity_to_triplets, self.meta_val_task_entity_to_triplets and self.meta_test_task_entity_to_triplets are disjoint respectively. Is this just a coincidence or a must? Because i have a question, if entity s is divided into train and entity o into test, the triplet (s,r,o) belongs to which? In this case, the triplets in train and test will not be disjoint.

About Training Gmatching MetaR and FSRL

Hi,

I am wondering how you train these methods in your task. As I understand, these three methods use entity pair matching and they do not use embeddings of sparse relations during training and evaluation. Do you also neglect the triple relations (relations in the triples containing unseen entities) while training them?

And also I think Gmatching, MetaR and FSRL are originally using meta-learning framework. What is the difference between, e.g., Gmatching and Gmatching*?

Task formulation for meta-learning enquiry

Hi there,
Firstly, thank you for your work.
I have read your paper and I have a few questions to clarify.
Mainly, how do you "... formulate a set of tasks such that the model
learns to generalize over unseen entities, which are simulated using seen entities." Your paper also mentioned sampling a task from the distribution p(T) but how is p(T) obtained? Is it predefined?

In other words, in the aspect of code, how did you pre-process your data such that it is split into meta-train/meta-valid/meta-test triplets?

self.filtered_triplets, self.meta_train_task_triplets, self.meta_valid_task_triplets, self.meta_test_task_triplets, \
        self.meta_train_task_entity_to_triplets, self.meta_valid_task_entity_to_triplets, self.meta_test_task_entity_to_triplets \
            = utils.load_processed_data('./Dataset/processed_data/{}'.format(args.data))

Other than that, do you mind elaborating on "our meta-learning framework can simulate the unseen entities during meta-training." cause I am still a confused by how your model works.

Thanks!!!

Question about pre-trained embedding setting

Hi,

thanks for your great work first!

I have a question about the pre-trained embedding generated with Distmult. Do we need to ignore "unseen entities" when we pre-train, i.e., remove all the triples which contain unseen entities? Or we just put the whole KG into the pre-training process, and then mask them in inductive/transductive training?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.