Giter Club home page Giter Club logo

owe's Introduction

An Open-World Extension for Knowledge Graph Completion Models

This repository contains the official Pytorch code for An Open-World Extension for Knowledge Graph Completion Models.

Setup

Resolve dependencies by executing the following command:

pip install -e .

Then download the FB15k-237-OWE, DBPedia50 and FB20k datasets as required. These contain the datasets in format required for both OpenKE and our code.

Usage

Training the KGC model

Before using OWE you need to train a KGC model. You can use any knowledge graph embedding framework for training. We used the PyTorch version of OpenKE.

To use a previously trained KGC model with OWE you need to export the entity and relation matrices as numpy arrays using pickle:

  • For TransE and DistMult the matrices are called entities.p and relations.p
  • For CompLEx entities_r.p, entities_i.p, relations_r.p and relations_i.p.

Furthermore you need to provide two more files: entity2id.txt and relation2id.txt, which contain a mapping of an entity/relation string to the corresponding index (id) in the embedding files.

The trained 300D ComplEx embeddings for FB15k-237-OWE can be obtained from here.

For closed-world evaluation:

python owe/run_closed_world.py -e -c <PATH_TO_DATASET> --<KGC_MODEL_NAME> <PATH_TO_KGC_EMBEDDINGS>

where KGC_MODEL_NAME can be complex, distmult or transe.

Instructions for OpenKE

Follow the instructions to install OpenKE. Under openke_scripts you can find exemplary training scripts (make sure you update the paths to the dataset in OpenKE format). As the API of OpenKE frequently changes, scripts work with the following version of OpenKE.

Training the Open-World Extension

Word embeddings are required for training the extension. You may obtain the wikipedia2vec word embeddings from here. An example config file to reproduce the results is provided as config.ini in the root folder.

For training:

python owe/run_open_world.py -t -c <PATH_TO_DATASET> -d  <PATH_TO_CONFIG_AND_OUTPUT_DIR> --<KGC_MODEL_NAME> <PATH_TO_KGC_EMBEDDINGS>

For evaluation:

python owe/run_open_world.py -e -lb -c <PATH_TO_DATASET> -d  <PATH_TO_CONFIG_AND_OUTPUT_DIR> --<KGC_MODEL_NAME> <PATH_TO_KGC_EMBEDDINGS>

Citation

If you found our work helpful in your research, consider citing the following:

@inproceedings{shah2019open,
  title={An Open-World Extension to Knowledge Graph Completion Models},
  author={Shah, Haseeb and Villmow, Johannes and Ulges, Adrian and Schwanecke, Ulrich and Shafait, Faisal},
  booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
  volume={33},
  pages={3044--3051},
  year={2019}
}

owe's People

Contributors

haseebs 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.