Skip to main content

Knowledge Graph Autoencoder Training Environment, bridging PyG encoders and TorchKGE decoders.

Project description

Knowledge Graph Autoencoder Training Environment (KGATE)

KGATE is a knowledge graph embedding library bridging the encoders from Pytorch Geometric and the decoders from TorchKGE.

This tool relies heavily on the performances of TorchKGE and its numerous implemented modules for link prediction, negative sampling and model evaluation. The main goal here is to address the lack of encoders in the original library, who is unfortunately not maintained anymore.

Installation

It is recommended to download the configuration template alongside your installation (see Usage below).

With pip

pip install kgate

From source

Clone this repository and install it in a virtual environment like so:

git clone git@github.com:BAUDOTlab/KGATE.git
python -m venv kge_env
source kge_env/bin/activate

Join the development

KGATE is developed using Poetry. If you want to contribute to KGATE or make your own modifications, follow these steps:

1. Install Poetry

pip install poetry

2. Clone the repository

git clone git@github.com:BAUDOTlab/KGATE.git

3. Install dependencies

cd KGATE
poetry install

Usage

KGATE is meant to be a self-sufficient training environment for knowledge graph embedding that requires very little code to work but can easily be expanded or modified. Everything stems from the Architect class, which holds all the necessary attributes and methods to fully train and test a KGE model following the autoencoder architecture, as well as run inference.

The configuration file lets you iterate quickly without changing your code. See the template to learn what the different options do.

At the very least, KGATE expects the Knowledge Graph to be given as a pandas dataframe or a CSV file with the columns "from", "to" and "rel", corresponding respectively to the head nodes, tail nodes and relation typesof the triplets, with one triplet per row. Any extra columns are ignored. In addition, a metadata dataframe can be submitted (can also be a CSV) to map each node with their type, requiring the columns "id" and "type". Extra columns are likewise ignored.

from kgate import Architect

config_path = "/path/to/your/config.toml"

architect = Architect(config_path = config_path)

# Train the model using KG and hyperparameters specified in the configuration
architect.train_model()

# Test the trained model, using the best checkpoint
architect.test()

# Run KG completion task, the empty list is the element that will be predicted
known_heads = []
known_relations = []
known_tails = []
architect.infer(known_heads, known_relations, known_tails)

For a more detailed example and specific methods that are available in the package, see the upcoming readthedocs documentation.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kgate-0.2.19.tar.gz (49.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kgate-0.2.19-py3-none-any.whl (56.7 kB view details)

Uploaded Python 3

File details

Details for the file kgate-0.2.19.tar.gz.

File metadata

  • Download URL: kgate-0.2.19.tar.gz
  • Upload date:
  • Size: 49.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/6.10.7-arch1-1

File hashes

Hashes for kgate-0.2.19.tar.gz
Algorithm Hash digest
SHA256 d01dc3d0e4e5bafe9b76d5635d638f3f219a84e11b673416c48d66571f38e20d
MD5 440eeadee0d7ec4073b3018ca1715246
BLAKE2b-256 1921b0d5177720674f40cc2a01fa4334e890659195f0524a24e191bf6a474f75

See more details on using hashes here.

File details

Details for the file kgate-0.2.19-py3-none-any.whl.

File metadata

  • Download URL: kgate-0.2.19-py3-none-any.whl
  • Upload date:
  • Size: 56.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/6.10.7-arch1-1

File hashes

Hashes for kgate-0.2.19-py3-none-any.whl
Algorithm Hash digest
SHA256 4e0d8cd4c723062a51db2554100910a86e283cedc39771aa095c43dbeac71c50
MD5 8d1d50b57c2b615a85103b8374c2fa1b
BLAKE2b-256 cdbf352eaa5a6566315f92a3aa2dc546ad38304cbc34d638d86cfa75371e2463

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page