Skip to content

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
albernar committed Mar 8, 2023
2 parents 97a0bb6 + 95c0f71 commit 71716ac
Show file tree
Hide file tree
Showing 256 changed files with 43,370 additions and 15,504 deletions.
35 changes: 15 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.common-values:

docker-image: &docker-image circleci/python:3.7.9
docker-image: &docker-image circleci/python:3.10

restore-cache: &restore-cache
keys:
Expand All @@ -19,7 +19,7 @@
name: Install package
command: |
. venv/bin/activate
venv/bin/python3 -m pip install tensorflow==1.15.5
venv/bin/python3 -m pip install tensorflow==2.10
venv/bin/python3 -m pip install .
version: 2
Expand Down Expand Up @@ -53,6 +53,7 @@ jobs:
test:
docker:
- image: *docker-image
resource_class: large
steps:
- checkout
- restore_cache: *restore-cache
Expand All @@ -63,8 +64,7 @@ jobs:
name: Unit tests with Pytest
command: |
. venv/bin/activate
venv/bin/python3 -m pytest tests
no_output_timeout: 60m
venv/bin/python3 setup.py test
lint:
docker:
- image: *docker-image
Expand All @@ -78,7 +78,7 @@ jobs:
command: |
. venv/bin/activate
venv/bin/python3 -m pip install flake8
venv/bin/python3 -m flake8 ampligraph --max-line-length 120 --ignore=W291,W293,W503
venv/bin/python3 -m flake8 ampligraph --max-line-length 200 --ignore=W605,W503,E231
docs:
docker:
Expand All @@ -105,34 +105,29 @@ workflows:
filters:
branches:
only:
- master
- develop
- /release\/.*/
- main
- ampligraph2/develop
- pip-check:
filters:
branches:
only:
- master
- develop
- /release\/.*/
- main
- ampligraph2/develop
- lint:
filters:
branches:
only:
- master
- develop
- /release\/.*/
- main
- ampligraph2/develop
- docs:
filters:
branches:
only:
- master
- develop
- /release\/.*/
- main
- ampligraph2/develop
- test:
filters:
branches:
only:
- master
- develop
- /release\/.*/
- main
- ampligraph2/develop
64 changes: 64 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml

# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: python:3.10.6

# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/topics/caching/
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
- venv/

before_script:
- python --version # For debugging
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install --upgrade pip
- pip install tensorflow==2.10

codestyle:
script:
- pip install pylint
- pylint --fail-under=3 -v ./ampligraph

test:
script:
- python setup.py test

run:
script:
- pip install wheel setuptools
- pip wheel --wheel-dir dist --no-deps .
artifacts:
paths:
- dist/*.whl

pages:
script:
- pip install sphinx sphinx-rtd-theme
- cd docs
- make clean autogen html
- mkdir ../public/
- mv _build/html/ ../public/
artifacts:
paths:
- public

deploy:
stage: deploy
script: echo "Define your deployment script!"
environment: production
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sphinx:
formats: all

python:
version: 3.7
version: 3.8
install:
- requirements: docs/requirements_readthedocs.txt
- method: setuptools
Expand Down
77 changes: 44 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

[![Documentation Status](https://readthedocs.org/projects/ampligraph/badge/?version=latest)](http://ampligraph.readthedocs.io/?badge=latest)

[![CircleCI](https://dl.circleci.com/status-badge/img/gh/Accenture/AmpliGraph/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/Accenture/AmpliGraph/tree/main)


[Join the conversation on Slack](https://join.slack.com/t/ampligraph/shared_invite/enQtNTc2NTI0MzUxMTM5LTRkODk0MjI2OWRlZjdjYmExY2Q3M2M3NGY0MGYyMmI4NWYyMWVhYTRjZDhkZjA1YTEyMzBkMGE4N2RmNTRiZDg)
![](docs/img/slack_logo.png)

Expand All @@ -30,66 +33,68 @@ It then combines embeddings with model-specific scoring functions to predict uns
![](docs/img/kg_lp_step2.png)


## Key Features
## AmpliGraph 2.0.0 is now available!
The new version features TensorFlow 2 back-end and Keras style APIs that makes it faster, easier to use and
extend the support for multiple features. Further, the data input/output pipeline has changed, and the support for
some obsolete models was discontinued.<br /> See the Changelog for a more thorough list of changes.


* **Intuitive APIs**: AmpliGraph APIs are designed to reduce the code amount required to learn models that predict links in knowledge graphs.
* **GPU-Ready**: AmpliGraph is based on TensorFlow, and it is designed to run seamlessly on CPU and GPU devices - to speed-up training.
* **Extensible**: Roll your own knowledge graph embeddings model by extending AmpliGraph base estimators.
## Key Features

* **Intuitive APIs**: AmpliGraph APIs are designed to reduce the code amount required to learn models that predict links in knowledge graphs. The new version AmpliGraph 2 APIs are in Keras style, making the user experience even smoother.
* **GPU-Ready**: AmpliGraph 2 is based on TensorFlow 2, and it is designed to run seamlessly on CPU and GPU devices - to speed-up training.
* **Extensible**: Roll your own knowledge graph embeddings model by extending AmpliGraph base estimators.

## Modules

AmpliGraph includes the following submodules:

* **Datasets**: helper functions to load datasets (knowledge graphs).
* **Models**: knowledge graph embedding models. AmpliGraph contains **TransE**, **DistMult**, **ComplEx**, **HolE**, **ConvE**, **ConvKB**. (More to come!)
* **Models**: knowledge graph embedding models. AmpliGraph 2 contains **TransE**, **DistMult**, **ComplEx**, **HolE** (More to come!)
* **Evaluation**: metrics and evaluation protocols to assess the predictive power of the models.
* **Discovery**: High-level convenience APIs for knowledge discovery (discover new facts, cluster entities, predict near duplicates).

* **Compat**: submodule that extends the compatibility of AmpliGraph 2 APIs to those of AmpliGraph 1.x for the user already familiar with them.

## Installation

### Prerequisites

* Linux, macOS, Windows
* Python 3.7
* Python ≥ 3.8

#### Provision a Virtual Environment

Create and activate a virtual environment (conda)

```
conda create --name ampligraph python=3.7
conda create --name ampligraph python=3.8
source activate ampligraph
```

#### Install TensorFlow

AmpliGraph is built on TensorFlow 1.x.
AmpliGraph 2 is built on TensorFlow 2.x.
Install from pip or conda:

**CPU-only**

```
pip install "tensorflow>=1.15.2,<2.0"
pip install "tensorflow>=2.9"
or
or
conda install tensorflow'>=1.15.2,<2.0.0'
conda install tensorflow'>=2.9'
```

**GPU support**
**Install TensorFlow 2 for Mac OS M1 chip**

```
pip install "tensorflow-gpu>=1.15.2,<2.0"
or
conda install tensorflow-gpu'>=1.15.2,<2.0.0'
conda install -c apple tensorflow-deps
pip install --user tensorflow-macos==2.10
pip install --user tensorflow-metal==0.6
```


In case of problems with installation refer to [Tensorflow Plugin page on Apple developer site](https://developer.apple.com/metal/tensorflow-plugin/).

### Install AmpliGraph

Expand All @@ -114,9 +119,9 @@ pip install -e .
### Sanity Check

```python
>> import ampligraph
>> ampligraph.__version__
'1.4.0'
>>> import ampligraph
>>> ampligraph.__version__
'2.0.0'
```


Expand All @@ -126,16 +131,20 @@ AmpliGraph includes implementations of TransE, DistMult, ComplEx, HolE, ConvE, a
Their predictive power is reported below and compared against the state-of-the-art results in literature.
[More details available here](https://docs.ampligraph.org/en/latest/experiments.html).

| |FB15K-237 |WN18RR |YAGO3-10 | FB15k |WN18 |
|------------------------------|----------|---------|-----------|------------|---------------|
| Literature Best | **0.35***| 0.48* | 0.49* | **0.84**** | **0.95*** |
| TransE (AmpliGraph) | 0.31 | 0.22 | **0.51** | 0.63 | 0.66 |
| DistMult (AmpliGraph) | 0.31 | 0.47 | 0.50 | 0.78 | 0.82 |
| ComplEx (AmpliGraph) | 0.32 | **0.51**| 0.49 | 0.80 | 0.94 |
| HolE (AmpliGraph) | 0.31 | 0.47 | 0.50 | 0.80 | 0.94 |
| ConvE (AmpliGraph) | 0.26 | 0.45 | 0.30 | 0.50 | 0.93 |
| ConvE (1-N, AmpliGraph) | 0.32 | 0.48 | 0.40 | 0.80 | **0.95** |
| ConvKB (AmpliGraph) | 0.23 | 0.39 | 0.30 | 0.65 | 0.80 |
| | FB15K-237 | WN18RR | YAGO3-10 | FB15k | WN18 |
|---------------------------|-----------|----------|----------|------------|-----------|
| Literature Best | **0.35*** | 0.48* | 0.49* | **0.84**** | **0.95*** |
| TransE (AmpliGraph 2) | 0.31 | 0.22 | 0.50 | 0.62 | 0.64 |
| DistMult (AmpliGraph 2) | 0.30 | 0.47 | 0.48 | 0.71 | 0.82 |
| ComplEx (AmpliGraph 2) | 0.31 | 0.50 | 0.49 | 0.73 | 0.94 |
| HolE (AmpliGraph 2) | 0.30 | 0.47 | 0.47 | 0.73 | 0.94 |
| TransE (AmpliGraph 1) | 0.31 | 0.22 | **0.51** | 0.63 | 0.66 |
| DistMult (AmpliGraph 1) | 0.31 | 0.47 | 0.50 | 0.78 | 0.82 |
| ComplEx (AmpliGraph 1) | 0.32 | **0.51** | 0.49 | 0.80 | 0.94 |
| HolE (AmpliGraph 1) | 0.31 | 0.47 | 0.50 | 0.80 | 0.94 |
| ConvE (AmpliGraph 1) | 0.26 | 0.45 | 0.30 | 0.50 | 0.93 |
| ConvE (1-N, AmpliGraph 1) | 0.32 | 0.48 | 0.40 | 0.80 | **0.95** |
| ConvKB (AmpliGraph 1) | 0.23 | 0.39 | 0.30 | 0.65 | 0.80 |

<sub>
* Timothee Lacroix, Nicolas Usunier, and Guillaume Obozinski. Canonical tensor decomposition for knowledge base
Expand Down Expand Up @@ -179,6 +188,8 @@ If you instead use AmpliGraph in an academic publication, cite as:
```
@misc{ampligraph,
author= {Luca Costabello and
Alberto Bernardi and
Adrianna Janik and
Sumit Pai and
Chan Le Van and
Rory McGrath and
Expand All @@ -194,4 +205,4 @@ If you instead use AmpliGraph in an academic publication, cite as:

## License

AmpliGraph is licensed under the Apache 2.0 License.
AmpliGraph is licensed under the Apache 2.0 License.
14 changes: 9 additions & 5 deletions ampligraph/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# Copyright 2019-2021 The AmpliGraph Authors. All Rights Reserved.
# Copyright 2019-2023 The AmpliGraph Authors. All Rights Reserved.
#
# This file is Licensed under the Apache License, Version 2.0.
# This file is Licensed under the Apache License, Version 2.0.0.
# A copy of the Licence is available in LICENCE, or at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
"""AmpliGraph is a library for relational learning on knowledge graphs."""
import logging.config
import pkg_resources

import pkg_resources
import tensorflow as tf

tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

__version__ = '1.4.0'
__version__ = '2.0.0'
__all__ = ['datasets', 'latent_features', 'discovery', 'evaluation', 'utils']

logging.config.fileConfig(pkg_resources.resource_filename(__name__, 'logger.conf'), disable_existing_loggers=False)
logging.config.fileConfig(
pkg_resources.resource_filename(__name__, "logger.conf"),
disable_existing_loggers=False,
)
12 changes: 12 additions & 0 deletions ampligraph/compat/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2019-2023 The AmpliGraph Authors. All Rights Reserved.
#
# This file is Licensed under the Apache License, Version 2.0.
# A copy of the Licence is available in LICENCE, or at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
"""Provides backward compatibility to AmpliGraph 1 APIs."""
from .evaluate import evaluate_performance
from .models import ComplEx, DistMult, HolE, TransE

__all__ = ["evaluate_performance", "TransE", "ComplEx", "DistMult", "HolE"]
Loading

0 comments on commit 71716ac

Please sign in to comment.