DyGMamba: Efficiently Modeling Long-Term Temporal Dependency on Continuous-Time Dynamic Graphs with State Space Models
This repository is built for our TMLR paper DyGMamba: Efficiently Modeling Long-Term Temporal Dependency on Continuous-Time Dynamic Graphs with State Space Models
The directory contains seven benchmark dataset and our work DyGMamba, which is an efficient continuous-time dynamic graph(CTDG) representation learning model that can capture long-term temporal dependencies. It also contains previous CTDG learning methods, including JODIE, DyRep, TGAT, TGN, CAWN, TCL, GrapnMixer and DyGFormer.
The code supports dynamic link prediction under both transductive and inductive settings with three (i.e., random, historical, and inductive) negative sampling strategies.
PyTorch, numpy, pandas, tqdm, tabulate, and mamba-ssm
To install the packages, run
pip install -r requirements.txt
We test our model using seven datasets: wikipedia, reddit, mooc, lastfm, enron, SocialEvo and uci. They can be downloaded. To run the training or evaluation, please download the datasets and put the unzipped file in processed_data folder.
For example, the directory of uci dataset should be structured as follows:
project-root/
└── processed_data/
└── uci/
├── ml_uci.csv
├── ml_uci.npy
└── ml_uci_node.npy
Dynamic link prediction could be performed on all the seven datasets. If you want to load the best model configurations determined by the grid search, please set the load_best_configs argument to True.
- Example of training DyGMamba on Wikipedia dataset:
python train_link_prediction.py --dataset_name wikipedia --model_name DyGMamba --patch_size 2 --max_input_sequence_length 64 --num_runs 5 --gpu 0
- If you want to use the best model configurations to train DyGMamba on Wikipedia dataset, run
python train_link_prediction.py --dataset_name wikipedia --model_name DyGMamba --load_best_configs --num_runs 5 --gpu 0
Three (i.e., random, historical, and inductive) negative sampling strategies can be used for model evaluation.
- Example of evaluating DyGMamba with random negative sampling strategy on Wikipedia dataset:
python evaluate_link_prediction.py --dataset_name wikipedia --model_name DyGMamba --patch_size 2 --max_input_sequence_length 64 --negative_sample_strategy random --num_runs 5 --gpu 0
- If you want to use the best model configurations to evaluate DyGMamba with random negative sampling strategy on Wikipedia dataset, run
python evaluate_link_prediction.py --dataset_name wikipedia --model_name DyGMamba --negative_sample_strategy random --load_best_configs --num_runs 5 --gpu 0