migalkin / StarE

EMNLP 2020: Message Passing for Hyper-Relational Knowledge Graphs
MIT License
87 stars 17 forks source link

StarE

Message Passing for Hyper-Relational Knowledge Graph.

DOI

Overview of StarE ...

StarE encodes hyper-relational fact by first passing Qualifier pairs through a composition function and then summed and transformed by . The resulting vector is then merged via , and with the relation and object vector, respectively. Finally, node Q937 aggregates messages from this and other hyper-relational edges. Please refer to the paper for details.

Requirements

Create a new conda environment and execute setup.sh. Alternatively

pip install -r requirements.txt

WD50K Dataset

The dataset can be found in data/clean/wd50k. Its derivatives can be found there as well:

More information available in dataset README

Running Experiments

Available models

Specified as MODEL_NAME in the running script

Datasets

Specified as DATASET in the running script

Starting training and evaluation

It is advised to run experiments on a GPU otherwise training might take long. Use DEVICE cuda to turn on GPU support, default is cpu. Don't forget to specify CUDA_VISIBLE_DEVICES before python if you use cuda Currently tested on cuda==12.1

Three parameters control triple/hyper-relational nature and max fact length:

The following scripts will train StarE (H) + Transformer (H) for 400 epochs and evaluate on the test set:

Triple-based models can be started with this basic set of params:

python run.py DATASET wd50k STATEMENT_LEN 3 MAX_QPAIRS 3 SAMPLER_W_QUALIFIERS False

More hyperparams are available in the CONFIG dictionary in the run.py.

If you want to adjust StarE encoder params prepend GCN_ to the params in the STAREARGS dict, e.g.,

python run.py DATASET wd50k GCN_GCN_DIM 80 GCN_QUAL_AGGREGATE concat

will construct StarE with hidden dim of 80 and concat as gamma function from the paper.

Integration with Weights & Biases (WANDB)

It's there out of the box! Create an account on WANDB Then, make sure you install the latest version of the package

pip install wandb

Locate your API_KEY in the user settings and activate it:

wandb login <api_key>

Then just use the CLI argument WANDB True, it will:

When using this codebase or dataset please cite:

@inproceedings{StarE,
  title={Message Passing for Hyper-Relational Knowledge Graphs},
  author={Galkin, Mikhail and Trivedi, Priyansh and Maheshwari, Gaurav and Usbeck, Ricardo and Lehmann, Jens},
  booktitle={EMNLP},
  year={2020}
}

For any further questions, please contact: mikhail.galkin@iais.fraunhofer.de