Giter Club home page Giter Club logo

kglib's Introduction

GitHub release Discord Discussion Forum Stack Overflow Stack Overflow

TypeDB KGLIB (Knowledge Graph Library)

KGLIB provides tools to enable machine learning with TypeDB.

This library is under development and will henceforth be transformed into primarily infrastructure tools and integrations between TypeDB and machine learning libraries.

Machine Learning Pipeline

Flow Diagram

The pipeline provided helps by allowing us to extract subgraphs from TypeDB. Each subgraph is a training example, which are sent to the learner in batches. Algorithms using this approach are scalable since they do not need to hold the whole graph in memory for training.

The pipeline is as follows:

  1. Extract data from TypeDB into Python NetworkX in-memory subgraphs by specifying multiple TypeQL queries.
  2. Encode the nodes and edges of the NetworkX graphs
  3. Either (a) transform the encoded values into features, ready for input into a graph/geometric learning pipeline (for example the upcoming PyTorch implementation); or (b) Embed the encoded values according to the Types present in your database (TensorFlow only, PyTorch coming soon). This type-centric embedding is crucial to extracting the context explicitly captured in TypeDB's Type System.
  4. Feed the features to a learning algorithm (see below)
  5. Optionally, store the predictions made by the learner in TypeDB. These predictions can then be queried using TypeQL. This means we can trivially run more learning tasks over the knowledge base, including the newly made predictions. This is knowledge graph completion.

Learning Algorithms

This repo contains one algorithmic implementation: Knowledge Graph Convolutional Network (KGCN). This is a generic method for relation predication over any TypeDB database. There is a full worked example and an explanation of how the approach works.

You are encouraged to use the tools available in KGLIB to interface TypeDB to your own algorithmic implementations, or to use/leverage prebuilt implementations available from popular libraries such as PyTorch Geometric or Graph Nets (TensorFlow/Sonnet).

Resources

You may find the following resources useful:

Quickstart

Requirements

  • Python >= 3.6, <= 3.7.x (TensorFlow 1.14.0 doesn't support later Python versions).

  • KGLIB installed via pip: pip install typedb-kglib.

  • TypeDB 2.1.1 running in the background.

  • typedb-client-python 2.1.0 (PyPi, GitHub release). This should be installed automatically when you pip install typedb-kglib.

Run the Example

Take a look at Knowledge Graph Convolutional Networks (KGCNs) to see a walkthrough of how to use the library.

Building from source

It's expected that you will use Pip to install, but should you need to make your own changes to the library, and import it into your project, you can build from source as follows.

Clone KGLIB:

git clone [email protected]:vaticle/kglib.git

Go into the project directory:

cd kglib

Build all targets:

bazel build //...

Run all tests. Requires Python 3.6+ on your PATH. Test dependencies are for Linux since that is the CI environment:

bazel test //kglib/... --test_output=streamed --spawn_strategy=standalone --action_env=PATH

Build the pip distribution. Outputs to bazel-bin:

bazel build //:assemble-pip

Development

To follow the development conversation, please join the Vaticle Discord, and join the #kglib channel. Alternatively, start a new topic on the Vaticle Discussion Forum.

KGLIB requires that you have migrated your data into a TypeDB or TypeDB Cluster instance. There is an official examples repo for how to go about this, and information available on migration in the docs. Alternatively, there are fantastic community-led projects growing in the TypeDB OSI to facilitate fast and easy data loading.

kglib's People

Contributors

dmitrii-ubskii avatar flyingsilverfin avatar gowtham1997 avatar grabl avatar haikalpribadi avatar jmsfltchr avatar vmax avatar

Watchers

 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.