Skip to content
This repository has been archived by the owner on Nov 18, 2023. It is now read-only.

Commit

Permalink
KGCN II - Relation prediction using DeepMind's Graph Nets (#85)
Browse files Browse the repository at this point in the history
## What is the goal of this PR?

Create a more versatile approach to KGCNs, one that can be customised to perform:
- Relation prediction
- Attribute value prediction
- Subgraph prediction
- Graph optimisation
- Generation of Concept embeddings

## What are the changes implemented in this PR?

Overwrites the entirety of the KGCN project with a more advanced version. This new approach uses a learned message-passing algorithm, implemented in TensorFlow. The algorithm can predict node, edge and global properties for any input graph.

Implemented is a method to predict new Relations in extracted subgraphs, picking from a provided set of candidate relations.

Solves #51, #78, #42
  • Loading branch information
jmsfltchr authored Sep 18, 2019
1 parent 5393b4a commit 88690ec
Show file tree
Hide file tree
Showing 123 changed files with 4,811 additions and 5,230 deletions.
99 changes: 82 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,24 @@ commands:
chmod +x bazel-0.25.2-installer-linux-x86_64.sh
sudo ./bazel-0.25.2-installer-linux-x86_64.sh
run-grakn-server:
steps:
- bazel_install
- run: bazel build @graknlabs_grakn_core//:assemble-linux-targz
- run: mkdir dist && tar -xvzf bazel-genfiles/external/graknlabs_grakn_core/grakn-core-all-linux.tar.gz -C ./dist/
- run: nohup ./dist/grakn-core-all-linux/grakn server start

jobs:
build:
machine: true
working_directory: ~/kglib
steps:
- checkout
- bazel_install
- run: pyenv install 3.6.3
- run: pyenv global 3.6.3
- run: bazel build //...

test:
machine: true
working_directory: ~/kglib
Expand Down Expand Up @@ -41,19 +58,29 @@ jobs:
- checkout
- run: pyenv install 3.6.3
- run: pyenv global 3.6.3
- run: wget https://storage.googleapis.com/kglib/grakn-core-all-mac-animaltrade1.5.3.zip
- run: unzip grakn-core-all-mac-animaltrade1.5.3.zip
- run: nohup grakn-core-all-mac-animaltrade1.5.3/grakn server start
- run-grakn-server
- run:
name: Run test-deployment-pip for kglib
command: |
echo -n "$(cat VERSION)-$CIRCLE_SHA1" > VERSION
sed -i -e "s/KGLIB_VERSION_MARKER/$(cat VERSION)/g" test/deployment/requirements.txt
cat test/deployment/requirements.txt
pip install -r test/deployment/requirements.txt
python -m unittest examples.kgcn.animal_trade.test.end_to_end_test
sed -i -e "s/KGLIB_VERSION_MARKER/$(cat VERSION)/g" tests/deployment/requirements.txt
cat tests/deployment/requirements.txt
pip install -r tests/deployment/requirements.txt
./dist/grakn-core-all-linux/grakn console -k diagnosis -f kglib/utils/grakn/synthetic/examples/diagnosis/schema.gql
python -m unittest kglib.kgcn.examples.diagnosis.diagnosis_end_to_end_test
deploy-git:
release-approval:
machine: true
working_directory: ~/kglib
steps:
- checkout
- bazel_install
- run: |
export RELEASE_APPROVAL_USERNAME=$REPO_GITHUB_USERNAME
export RELEASE_APPROVAL_TOKEN=$REPO_GITHUB_TOKEN
bazel run @graknlabs_build_tools//ci:release-approval
deploy-github:
machine: true
working_directory: ~/kglib
steps:
Expand All @@ -79,28 +106,66 @@ jobs:
export DEPLOY_PIP_PASSWORD=$REPO_PYPI_PASSWORD
bazel run //:deploy-pip -- release
release-cleanup:
machine: true
steps:
- checkout
- run: git push --delete origin kglib-release-branch

workflows:
version: 2
kglib:
jobs:
- test
- test:
filters:
branches:
ignore: kglib-release-branch
- build:
filters:
branches:
ignore: kglib-release-branch
- deploy-pip-snapshot:
filters:
branches:
only: master
requires:
- test
- build
- test-deployment-pip:
filters:
branches:
only: master
requires:
- deploy-pip-snapshot
- approve-deploy-git:
type: approval
- release-approval:
filters:
branches:
only: master
requires:
- test-deployment-pip
- deploy-git:
requires:
- approve-deploy-git
- approve-deploy-pip-release:

kglib-release:
jobs:
- deploy-github:
filters:
branches:
only: kglib-release-branch
- deploy-approval:
type: approval
filters:
branches:
only: kglib-release-branch
requires:
- deploy-git
- deploy-github
- deploy-pip-release:
filters:
branches:
only: kglib-release-branch
requires:
- deploy-approval
- release-cleanup:
filters:
branches:
only: kglib-release-branch
requires:
- approve-deploy-pip-release
- deploy-pip-release
44 changes: 38 additions & 6 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,44 @@ assemble_pip(
author = "Grakn Labs",
author_email = "community@grakn.ai",
license = "Apache-2.0",
install_requires=['absl-py==0.5.0', 'astor==0.7.1', 'decorator==4.3.0', 'gast==0.2.0', 'grakn-client==1.5.3', 'h5py==2.8.0',
'Keras-Applications==1.0.6', 'Keras-Preprocessing==1.0.5',
'Markdown==3.0.1', 'networkx==2.2', 'numpy==1.15.2', 'protobuf==3.6.1', 'scikit-learn==0.20.1',
'scipy==1.1.0', 'six==1.11.0', 'tensorboard==1.11.0', 'tensorflow==1.11.0',
'tensorflow-hub==0.1.1', 'termcolor==1.1.0', 'Werkzeug==0.14.1',
'grpcio==1.16.0', 'protobuf==3.6.1', 'six==1.11.0', 'enum34==1.1.6', 'twine==1.12.1', 'requests==2.21.0'],
install_requires=[
'enum-compat==0.0.2',
'grakn-client==1.5.4',
'absl-py==0.8.0',
'astor==0.8.0',
'cloudpickle==1.2.2',
'contextlib2==0.5.5',
'cycler==0.10.0',
'decorator==4.4.0',
'dm-sonnet==1.35',
'future==0.17.1',
'gast==0.3.1',
'google-pasta==0.1.7',
'graph-nets==1.0.4',
'grpcio==1.23.0',
'h5py==2.10.0',
'Keras-Applications==1.0.8',
'Keras-Preprocessing==1.1.0',
'kiwisolver==1.1.0',
'Markdown==3.1.1',
'matplotlib==3.1.1',
'networkx==2.3',
'numpy==1.17.2',
'pandas==0.25.1',
'protobuf==3.9.1',
'pyparsing==2.4.2',
'python-dateutil==2.8.0',
'pytz==2019.2',
'semantic-version==2.8.2',
'six==1.12.0',
'tensorboard==1.14.0',
'tensorflow==1.14.0',
'tensorflow-estimator==1.14.0',
'tensorflow-probability==0.7.0',
'termcolor==1.1.0',
'Werkzeug==0.15.6',
'wrapt==1.11.2',
],
keywords = ["machine learning", "logical reasoning", "knowledege graph", "grakn", "database", "graph",
"knowledgebase", "knowledge-engineering"],

Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,35 @@ To respond to these scenarios, KGLIB is the centre of all research projects cond

At present this repo contains one project: [*Knowledge Graph Convolutional Networks* (KGCNs)](https://github.com/graknlabs/kglib/tree/master/kglib/kgcn).

## Quickstart
**Requirements**

- Python 3.7

- Install via pip: `pip install grakn-kglib`

- The [latest release of Grakn Core](https://github.com/graknlabs/grakn/releases/latest) or [Grakn KGMS](https://dev.grakn.ai/docs/cloud-deployment/kgms) running

**Building from source**

To test that all targets can be built:

```bash
bazel build //...
```

To run all tests:

```bash
bazel test //... --test_output=streamed --spawn_strategy=standalone --python_version PY3 --python_path $(which python3)
```

To build the pip distribution (find the output in `bazel-bin`):

```bash
bazel build //:assemble-pip
```

## Knowledge Graph Tasks

Below is a set of tasks to be conducted over Knowledge Graphs (KGs) that we have identified from real Grakn use cases. The objective of KGLIB is to implement a portfolio of solutions for these tasks for Grakn Knowledge Graphs.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.1
0.2
77 changes: 0 additions & 77 deletions examples/kgcn/animal_trade/README.md

This file was deleted.

Loading

0 comments on commit 88690ec

Please sign in to comment.