Paddle Graph Learning
Project description
DOC | Quick Start | 中文
Breaking News !!
One amazing paper about knowledge representation learning was accepted! (2022.05.06)
- Simple and Effective Relation-based Embedding Propagation for Knowledge Representation Learning, to appear in IJCAI2022. Code can be found here.
PGL v2.2 2021.12.20
-
Graph4Rec: We released a universal and large-scale toolkit with graph neural networks for recommender systems. Details can be found here.
-
Graph4KG: We released a flexible framework named Graph4KG to learn embeddings of entities and relations in KGs, which supports training on massive KGs. Details can be found here.
-
GNNAutoScale: PGL now supports GNNAutoScale framework, which can scale arbitrary message-passing GNNs to large graphs. Details can be found here.
🔥 🔥 🔥 OGB-LSC KDD CUP 2021 winners announced!! (2021.06.17)
Super excited to announce our PGL team won TWO FIRST place and ONE SECOND place in a total of three track in OGB-LSC KDD CUP 2021. Leaderboards can be found here.
-
First place in MAG240M-LSC track: Code and Technical Report can be found here.
-
First place in WikiKG90M-LSC track: Code and Technical Report can be found here.
-
Second place in PCQM4M-LSC track: Code and Technical Report can be found here.
Two amazing paper using PGL are accepted: (2021.06.17)
- Masked Label Prediction: Unified Message Passing Model for Semi-Supervised Classification, to appear in IJCAI2021.
- HGAMN: Heterogeneous Graph Attention Matching Network for Multilingual POI Retrieval at Baidu Maps, to appear in KDD2021.
PGL Dstributed Graph Engine API released!!
- Our Dstributed Graph Engine API has been released and we developed a tutorial to show how to launch a graph engine and a demo for training model using graph engine.
Paddle Graph Learning (PGL) is an efficient and flexible graph learning framework based on PaddlePaddle.
The newly released PGL supports heterogeneous graph learning on both walk based paradigm and message-passing based paradigm by providing MetaPath sampling and Message Passing mechanism on heterogeneous graph. Furthermor, The newly released PGL also support distributed graph storage and some distributed training algorithms, such as distributed deep walk and distributed graphsage. Combined with the PaddlePaddle deep learning framework, we are able to support both graph representation learning models and graph neural networks, and thus our framework has a wide range of graph-based applications.
One of the most important benefits of graph neural networks compared to other models is the ability to use node-to-node connectivity information, but coding the communication between nodes is very cumbersome. At PGL we adopt Message Passing Paradigm similar to DGL to help to build a customize graph neural network easily. Users only need to write send
and recv
functions to easily implement a simple GCN. As shown in the following figure, for the first step the send function is defined on the edges of the graph, and the user can customize the send function to send the message from the source to the target node. For the second step, the recv function is responsible for aggregating messages together from different sources.
To write a sum aggregator, users only need to write the following codes.
import pgl
import paddle
import numpy as np
num_nodes = 5
edges = [(0, 1), (1, 2), (3, 4)]
feature = np.random.randn(5, 100).astype(np.float32)
g = pgl.Graph(num_nodes=num_nodes,
edges=edges,
node_feat={
"h": feature
})
g.tensor()
def send_func(src_feat, dst_feat, edge_feat):
return src_feat
def recv_func(msg):
return msg.reduce_sum(msg["h"])
msg = g.send(send_func, src_feat=g.node_feat)
ret = g.recv(recv_func, msg)
Highlight: Flexibility - Natively Support Heterogeneous Graph Learning
Graph can conveniently represent the relation between things in the real world, but the categories of things and the relation between things are various. Therefore, in the heterogeneous graph, we need to distinguish the node types and edge types in the graph network. PGL models heterogeneous graphs that contain multiple node types and multiple edge types, and can describe complex connections between different types.
Support meta path walk sampling on heterogeneous graph
The left side of the figure above describes a shopping social network. The nodes above have two categories of users and goods, and the relations between users and users, users and goods, and goods and goods. The right of the above figure is a simple sampling process of MetaPath. When you input any MetaPath as UPU (user-product-user), you will find the following results Then on this basis, and introducing word2vec and other methods to support learning metapath2vec and other algorithms of heterogeneous graph representation.
Support Message Passing mechanism on heterogeneous graph
Because of the different node types on the heterogeneous graph, the message delivery is also different. As shown on the left, it has five neighbors, belonging to two different node types. As shown on the right of the figure above, nodes belonging to different types need to be aggregated separately during message delivery, and then merged into the final message to update the target node. On this basis, PGL supports heterogeneous graph algorithms based on message passing, such as GATNE and other algorithms.
Large-Scale: Support distributed graph storage and distributed training algorithms
In most cases of large-scale graph learning, we need distributed graph storage and distributed training support. As shown in the following figure, PGL provided a general solution of large-scale training, we adopted PaddleFleet as our distributed parameter servers, which supports large scale distributed embeddings and a lightweighted distributed storage engine so it can easily set up a large scale distributed training algorithm with MPI clusters.
Model Zoo
The following graph learning models have been implemented in the framework. You can find more examples and the details here.
Model | feature |
---|---|
ERNIESage | ERNIE SAmple aggreGatE for Text and Graph |
GCN | Graph Convolutional Neural Networks |
GAT | Graph Attention Network |
GraphSage | Large-scale graph convolution network based on neighborhood sampling |
unSup-GraphSage | Unsupervised GraphSAGE |
LINE | Representation learning based on first-order and second-order neighbors |
DeepWalk | Representation learning by DFS random walk |
MetaPath2Vec | Representation learning based on metapath |
Node2Vec | The representation learning Combined with DFS and BFS |
Struct2Vec | Representation learning based on structural similarity |
SGC | Simplified graph convolution neural network |
GES | The graph represents learning method with node features |
DGI | Unsupervised representation learning based on graph convolution network |
GATNE | Representation Learning of Heterogeneous Graph based on MessagePassing |
The above models consists of three parts, namely, graph representation learning, graph neural network and heterogeneous graph learning, which are also divided into graph representation learning and graph neural network.
System requirements
PGL requires:
- paddlepaddle >= 2.2.0
- cython
PGL only supports Python 3
Installation
You can simply install it via pip.
pip install pgl
The Team
PGL is developed and maintained by NLP and Paddle Teams at Baidu
E-mail: nlp-gnn[at]baidu.com
License
PGL uses Apache License 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file pgl-2.2.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pgl-2.2.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 9.3 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 821b508805811eb960836b7f37dc48f38b7d959c941d397c41b12f13cd858fdd |
|
MD5 | 7bd80bf6359290fb9f0ffd5c51f40ca0 |
|
BLAKE2b-256 | b22ad2389e33e9fb489310ca54ac904f23ca9c9faf4031a96f14742bfe1e161d |
File details
Details for the file pgl-2.2.6-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: pgl-2.2.6-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 9.1 MB
- Tags: CPython 3.8, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7da51d3d6434e40dc7d5e42882c2f0c2407e54869d1b0cb547a61b27ca1d005 |
|
MD5 | 28567dd11a621a3cc70c675b696f84c5 |
|
BLAKE2b-256 | f20e98ce39ac5f38afc8574ac2fa92f9317b8f283bf3b631203359389989204c |
File details
Details for the file pgl-2.2.6-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pgl-2.2.6-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 8.4 MB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4544e40827152ef29d41f192e0077c6a6558d590d04ad4cb6e17b00b5378ef76 |
|
MD5 | 779b3a8f1c927e913bcd8cb5bca7c7e9 |
|
BLAKE2b-256 | 633445c9831c20cdb58c7467dcc922cf9afd2a779fd25dd50446d11ef85a0772 |
File details
Details for the file pgl-2.2.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pgl-2.2.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea6329977c5da6d02f49adf672f40401c2b0d6ac3332f7a178eeb6a209f96a18 |
|
MD5 | ea6b9ccc9c22c5e95533b5e89fa9dbbd |
|
BLAKE2b-256 | 6b327e8bcf8682ec6caad6e5f3b52798523edeeb1d6ca9b5d3d2569d85515850 |
File details
Details for the file pgl-2.2.6-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: pgl-2.2.6-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 9.1 MB
- Tags: CPython 3.7m, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bee5791eb6d8d0e856df2abbeaf47ed7aeec25428b21030f4d74b3fcb9cab136 |
|
MD5 | f263c2a28195243a653bb501bec03a59 |
|
BLAKE2b-256 | 2f8556112f0adc3ee912f3e49039c3e40cff2c74274a5a77ae144611d8e494d6 |
File details
Details for the file pgl-2.2.6-cp37-cp37m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pgl-2.2.6-cp37-cp37m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 8.4 MB
- Tags: CPython 3.7m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20ff4d788620eaef2bd6fc9ef730d733f5c8c252ba66f32e0db6d196d8d0baf5 |
|
MD5 | 9b9d54b883a5bb8c50e3abcbe063ca46 |
|
BLAKE2b-256 | d8c3da62a48ee8bf1fa7aa4d1ab4e0ecbec489bd1d16b6facecb0b2bb4a218b0 |
File details
Details for the file pgl-2.2.6-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pgl-2.2.6-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f0871ec9dd1d798faac8f7b2536f8a0cc5182be8e2806c68a3b48dcf6ca73b3 |
|
MD5 | 3aaf6b7d84ee82b9a146fd2d5db529bc |
|
BLAKE2b-256 | cc9b7aab09722525ca8dd3344d165dfc90f3e826526d80a63e2fe4414c3b29f1 |
File details
Details for the file pgl-2.2.6-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: pgl-2.2.6-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 9.0 MB
- Tags: CPython 3.6m, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3ae5f76e363d99deabb86fae23dd4c9fcde557d9d52ca6901f22d06ff548eb9 |
|
MD5 | 414343a4e47f00d05eca757cf292e893 |
|
BLAKE2b-256 | b0539f4b57aad598612126a7f1008fdcf2aff7a16f5ac2b6f7036fdf7900cc39 |
File details
Details for the file pgl-2.2.6-cp36-cp36m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pgl-2.2.6-cp36-cp36m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 8.4 MB
- Tags: CPython 3.6m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bab57d5d2d658b334a0f3947a6c8b9daf34dee8dac10fda2aa168b1ee45aa63 |
|
MD5 | 9696121f4ac09907de890ab76e26169d |
|
BLAKE2b-256 | b1675a5c600278c280cf36c3cbf2431262ed1ea38329c6ac35bfa28e9a2c2633 |