GraphAlign: Pretraining One Graph Neural Network on Multiple Graphs via Feature Alignment

September 17, 2024 · View on GitHub

Paper link: arxiv

Dependencies

  1. PyTorch >= v2.1.1 and CUDA >= 11.4 are recommended.

  2. dgl >= 0.7.2

  3. localclustering (optional for data preprocessing)

  4. Run bash setup.sh to install necessary dependences, including fmoe.

  5. You can use wandb to monitor the training process.

Dataset Preprocessing

For Large scale graphs, before starting mini-batch training, you'll need to generate local clusters if you want to use local-clustering for training. To generate a local cluster, you should first install localclustering and then run the following command:

python generate_data.py \
	--data_save_path <path/to/data_dir> \
	--device <gpu_id> \
	--batch_size 512 \
	--dataset_name ogbn-arxiv ogbn-products ogbn-papers100M FB15K237 Cora WN18RR

And we also provide the pre-generated local clusters which can be downloaded here for usage.

Pretrained Model Download

You can download our pretrainded model here and run below code to eval our model.

# Eval download pretrained model (linear probe result)
bash scripts/evaluation.sh <gpu_id> <path/to/data> <path/to/download/gnn_ckpt>
# Eval download pretrained model (few-shot result) 
bash scripts/few_shot_eval.sh <gpu_id> <path/to/data> <path/to/download/gnn_ckpt>

Quick Start

To reproduce individually pretraining results, run: (first param is device, second param is path/to/save/data)

bash scripts/individually_pretrain.sh 0 your/path/to/save/data

To reproduce GraphAlign results,

# For GNN pretraining
# Multi-GPU training is supported. <gpu_ids> can be set as "0,1" or more gpus.
bash scripts/graphalign.sh <gpu_ids> <path/to/data>

# Evaluation after GNN pretraining checkpoint
bash scripts/evaluation.sh <gpu_id> <path/to/data> <path/to/gnn_ckpt>

To reproduce few-shot results:

# Evaluate the pretraining GNN in few-shot classification
bash scripts/few_shot_eval.sh <gpu_id> <path/to/data> </path/to/gnn_ckpt>

Experimental Results

  • Linear probing results in unsupervised representation learning for node classification
MethodSettingogbn-arxivogbn-productsogbn-papers100MAvg. gain
MLPsupervised69.85±0.3673.74±0.4356.62±0.21-
GATsupervised74.15±0.1583.42±0.3566.63±0.23-
GCNsupervised74.77±0.3480.76±0.5068.15±0.08-
SGCsupervised71.56±0.4174.36±0.2758.82±0.08-
BGRLindividually-pretrain72.98±0.1480.45±0.1665.40±0.23-
vanilla jointly-pretrain69.00±0.0881.11±0.2763.93±0.22-1.60
GraphAlign73.20±0.2080.79±0.4565.62±0.14+0.26
GRACEindividually-pretrain73.33±0.1981.91±0.2765.59±0.13-
vanilla jointly-pretrain72.10±0.1881.96±0.3465.54±0.18-0.41
GraphAlign73.69±0.2681.90±0.1965.61±0.17+0.12
GraphMAEindividually-pretrain72.35±0.1281.69±0.1165.68±0.28-
vanilla jointly-pretrain71.98±0.2482.36±0.1965.92±0.13+0.18
GraphAlign72.97±0.2282.51±0.1866.08±0.18+0.61
GraphMAE2individually-pretrain73.10±0.1182.53±0.1766.28±0.10-
vanilla jointly-pretrain71.28±0.2580.05±0.3564.28±0.33-2.10
GraphAlign73.56±0.2682.93±0.4266.39±0.14+0.32
  • Few-shot node classification results on ogbn-arxiv and Cora, and link classification results on FB15K237 and WN18RR. We report m-way-k-shot accuracy(%), i.e., 5-way for ogbn-arxiv, Cora, WN18RR and 20-way for FB15K237.
Methodogbn-arxiv 5-shotogbn-arxiv 1-shotCora 5-shotCora 1-shotWN18RR 5-shotWN18RR 1-shotFB15K237 5-shotFB15K237 1-shot
GPN50.53±3.0738.58±1.61------
TENT60.83±7.4545.62±10.70------
GLITTER56.00±4.4047.12±2.73------
Prodigy61.09±5.8548.23±6.18----74.92±6.0355.49±6.88
OFA61.45±2.5650.20±4.2748.76±2.6534.04±4.1046.32±4.1833.86±3.4182.56±1.5875.39±2.86
OFA-emb-only61.27±7.0943.22±8.4558.60±6.7240.87±8.2654.87±9.7339.72±9.3559.11±6.9543.03±7.17
GraphAlign(GraphMAE)81.93±6.2265.02±10.6274.49±6.4355.55±9.8660.19±10.3145.08±10.5579.92±5.5463.01±7.29
GraphAlign(GraphMAE2)83.97±5.8570.65±10.4573.66±6.7556.87±9.9855.95±10.4942.22±10.0479.86±5.5363.56±7.31
GraphAlign(GRACE)84.76±5.7171.18±10.2969.85±7.1952.60±10.1053.11±10.2439.58±9.4275.04±5.9860.09±7.36
GraphAlign(BGRL)81.88±6.2666.31±10.6368.13±6.8450.19±9.4951.97±10.6638.72±9.7777.74±5.8761.48±7.44
E5-emb-only65.67±7.0247.13±8.6859.71±6.7141.58±8.1156.52±9.6541.53±9.3658.43±6.9442.06±7.11

Citing

If you find this work is helpful to your research, please consider citing our paper:

@article{hou2024graphalign,
  title={GraphAlign: Pretraining One Graph Neural Network on Multiple Graphs via Feature Alignment},
  author={Hou, Zhenyu and Li, Haozhan and Cen, Yukuo and Tang, Jie and Dong, Yuxiao},
  journal={arXiv preprint arXiv:2406.02953},
  year={2024}
}