GithubHelp home page GithubHelp logo

suriya-1403 / cmpnn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hxyscotthuang/cmpnn

0.0 0.0 0.0 398 KB

The official implementation of "A Theory of Link Prediction via Relational Weisfeiler-Leman on Knowledge Graphs" (NeurIPS 2023)

License: MIT License

Python 28.45% Jupyter Notebook 71.55%

cmpnn's Introduction

A Theory of Link Prediction via Relational Weisfeiler-Leman on Knowledge Graphs

This is the official code base of the NeurIPS 2023 paper A Theory of Link Prediction via Relational Weisfeiler-Leman on Knowledge Graphs (ArXiv) based on PyTorch and TorchDrug, with implemented Conditional Message Passing Neural Network (C-MPNN). It is largely based on the NBFNet code base , with mild modifications to accommodate all models studied in the paper. Also, it supports training and inference with multiple GPUs or multiple machines.

Installation

pip install torch
pip install torchdrug
pip install ogb easydict pyyaml

Reproduction

To reproduce the experiment in the paper, use the following command. Alternatively, you may use --gpus null to run C-MPNN on a CPU. All the datasets will be automatically downloaded in the code.

python script/run.py -c config/inductive/wn18rr.yaml --gpus [0] --version v1

For experiments on inductive relation prediction, you need to additionally specify the split version with --version v1.

For CPU only, run the following command

python script/run.py -c config/inductive/wn18rr.yaml --gpus null --version v1

To run C-MPNN with multiple GPUs or multiple machines, use the following commands

python -m torch.distributed.launch --nproc_per_node=4 script/run.py -c config/inductive/wn18rr.yaml --gpus [0,1,2,3]
python -m torch.distributed.launch --nnodes=4 --nproc_per_node=4 script/run.py -c config/inductive/wn18rr.yaml --gpus [0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3]

Configuration

We provide the hyperparameters for each experiment in configuration files. All the configuration files can be found in config/*/*.yaml.

Inductive Relation Prediction Experiments

The naming and the corresponding model variation are shown below.

Model Architecture Choice Key Value
Aggregate Function Principal Neighborhood Aggregation(PNA) aggregate_func pna
Sum sum
Message Function ${Mes}_r^{1}(\mathbf{h}_{w \mid u,q}^{(t)},\mathbf{z}_q) = \mathbf{h}_{w \mid u,q}^{(t)} * \mathbf{W}_{r}^{(t)} \mathbf{z}_q $ (dependent, rgcn) (yes,no)
${Mes}_r^{2}(\mathbf{h}_{w \mid u,q}^{(t)},\mathbf{z}_q) = \mathbf{h}_{w \mid u,q}^{(t)} * \mathbf{b}_r $ (no,no)
${Mes}_r^{3}(\mathbf{h}_{w \mid u,q}^{(t)},\mathbf{z}_q) = \mathbf{W}_{r}^{(t)}\mathbf{h}_{w \mid u,q}^{(t)} $ (_,yes)
History Function $f(t) = t$ set_boundary no
$f(t) = 0$ yes

In addition, if we consider using ${Mes}_r^3$, then we can pass in additional parameter num_bases: k where k is the number of basis for basis decomposition.

Initialization Experiments

The naming in the config file and the corresponding model variation are shown below.

Initialization Equation
AllZero ${Init}_0(u,v,q) = \mathbf{0}$
Zero-One ${Init}_1(u,v,q) = \mathbb{1}_{u = v} * \mathbf{1}$
Query ${Init}_2(u,v,q) = \mathbb{1}_{u = v} * \mathbf{z}_q $
QueryWithNoise ${Init}_3(u,v,q) = \mathbb{1}_{u = v} * (\mathbf{z}_q + \mathbf{\epsilon}_{u})$

Transductive Experiments

For experiments on transductive relation prediction:

python script/run.py -c config/knowledge_graph/wn18rr.yaml --gpus [0] 

Readout Experiments

The TRI-SQR dataset and synthetic experiments are shown in TRI-SQR dataset.ipynb

The key and acceptable values in the config file:

Key Value
has_readout yes / no
readout_type sum/ mean
query_specific_readout yes / no

For further details please refer to the NBFNet code base.

@inproceedings{
huang2023a,
title={A Theory of Link Prediction via Relational Weisfeiler-Leman on Knowledge Graphs},
author={Xingyue Huang and Miguel Romero Orth and İsmail İlkan Ceylan and Pablo Barceló},
booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
year={2023},
url={https://openreview.net/forum?id=7hLlZNrkt5}
}

cmpnn's People

Contributors

hxyscotthuang avatar suriya-1403 avatar

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.