Giter VIP home page Giter VIP logo

polo's Introduction

Neural Multi-Hop Reasoning With Logical Rules on Biomedical Knowledge Graphs

Tensorflow implementation of the method PoLo from this paper.

Credits

This implementation is based on Shehzaad Dhuliawala's repository, which contains the code for the paper Go for a Walk and Arrive at the Answer - Reasoning over Paths in Knowledge Bases using Reinforcement Learning.

How To Run

The dependencies are specified in requirements.txt. To run PoLo, use one of the config files or create your own. For an explanation of each hyperparameter, refer to the README file in the configs folder.

Then, run the command

./run.sh configs/${config_file}.sh

Data Format

Triple format

KG triples need to be written in the format subject predicate object, with tabs as separators. Furthermore, PoLo uses inverse relations, so it is important to add the inverse triple for each fact in the KG. The prefix _ is used before a predicate to signal the inverse relation, e.g., the inverse triple for Germany hasCapital Berlin is Berlin _hasCapital Germany.

File format

Datasets should have the following files:

dataset
    ├── train.txt
    ├── dev.txt
    ├── test.txt
    ├── graph.txt
    └── rules.txt

Where:

train.txt contains all train triples.

dev.txt contains all validation triples.

test.txt contains all test triples.

graph.txt contains all triples of the KG except for dev.txt, test.txt, the inverses of dev.txt, and the inverses of test.txt.

rules.txt contains the rules as a dictionary, where the keys are the head relations. The rules for a specific relation are stored as a list of lists (sorted by decreasing confidence), where a rule is expressed as [confidence, head relation, body relation, ..., body relation].

For Hetionet, the complete graph is split into graph.txt (no inverse triples) and graph_inverses.txt (inverse triples) because of the file size constraints on GitHub.

For rules learned by the method AnyBURL, the script preprocess_rule_list.py can be used to preprocess the rules into the format that is needed for PoLo.

Finally, two vocab files are needed, one for the entities and one for the relations. These can be created by using the create_vocab.py file.

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.