DerwenAI / kglab

Graph Data Science: an abstraction layer in Python for building knowledge graphs, integrated with popular graph libraries – atop Pandas, NetworkX, RAPIDS, RDFlib, pySHACL, PyVis, morph-kgc, pslpython, pyarrow, etc.
https://derwen.ai/docs/kgl/
MIT License
565 stars 64 forks source link

KGE and GNN - support and examples #30

Open ceteri opened 3 years ago

ceteri commented 3 years ago

Add support for knowledge graph embedding (KGE), to build on the UMAP example, based on DeepWalk, node2vec, etc., used to handle the semantic tagging of the full recipe dataset.

Depends on: #29

Tutorials to evaluate:

Code repos to evaluate:

Papers to recommend:

ceteri commented 3 years ago

Tutorial about PyTorch Geometric https://towardsdatascience.com/hands-on-graph-neural-networks-with-pytorch-pytorch-geometric-359487e221a8

dvsrepo commented 3 years ago

Hi Paco!

I will start working on this next week, PyTorch geometric seems like a good choice to start working out the details, focusing on an application to the full recipe example.

ceteri commented 3 years ago

@dvsrepo just added as_tensor() method to SubgraphTensor to support the PyTorch_Geometric use case with Rubrix

igrangel commented 2 years ago

@ceteri @dvsrepo do you have an example of the integration with PyTorch Geometric? Currently, I'm using the following:

from torch_geometric.utils import from_networkx pG = from_networkx(G)

Assuming that the G is the result of a SPARQL query fetching everything in the graph. This is for sure not a good solution, I would be interested in your solution here.

dvsrepo commented 2 years ago

Hi Irlan! Nice to hear from you 😊

The current implementation is quite slow and I've planning to improve it for a long time now :( hopefully will do this beginning of September, but it uses the Subgraph class, you can find the reference here: https://derwen.ai/docs/kgl/ref/#kglab.SubgraphTensor.as_tensor

A faster way to do it is shown in the following tutorial which also shows how to train a gcn and transform URIs to tensor IDs and viceversa: https://docs.rubrix.ml/en/stable/tutorials/03-kglab_pytorch_geometric.html#2.-Representing-our-knowledge-graph-as-a-PyTorch-Tensor

Any suggestions to improve the implementation in kglab is more than welcome