A framework for deep learning on graphs that change over time, developed at Twitter. Cited over 2,000 times, with 1,200+ stars on GitHub.
A dynamic graph is a stream of timestamped events (follows, tweets, retweets). TGN learns from this stream to predict, for example, which edges will appear next.
Emanuele Rossi, Ben Chamberlain, Fabrizio Frasca, Davide Eynard, Federico Monti, Michael Bronstein ICML 2020 Workshop on Graph Representation Learning
Most graph neural networks assume a graph that does not change. Many real systems are not like that: nodes and edges keep appearing over time in social networks, financial transactions and recommender systems, but also across science, from the contact networks through which epidemics spread, to interactions between proteins or brain regions, to the social structure of animal groups. Temporal Graph Networks (TGN) learn directly from such a graph seen as a continuous stream of timestamped events.
The key idea is a memory for every node: a compact summary of everything that node has been involved in so far, updated each time a new event touches it. When the model needs a representation of a node, it combines this memory with information from the node’s recent neighbours through a graph attention layer. This makes TGN both more accurate and more efficient than previous approaches to dynamic graphs.
How it works
TGN is a framework made of a few interchangeable modules:
Memory: a state vector per node, storing its history in compressed form.
Message function: when an event (e.g. an interaction between two nodes) happens, it computes a message for each node involved.
Memory updater: a recurrent network (such as a GRU) that updates each node’s memory with its new messages.
Embedding module: computes up-to-date node embeddings by aggregating memories of temporal neighbours with graph attention. This also handles nodes whose memory is stale because they have not been active recently.
How TGN processes a batch of interactions during training: (1) compute node embeddings from the current memory, (2) decode them into edge probabilities and (3) compute the loss; then (4) build messages from the batch and (5) use them to update the memory of the nodes involved.
Several earlier models for dynamic graphs, such as JODIE, DyRep and TGAT, can be expressed as particular choices of these modules. The paper includes an ablation study of the different components and identifies the best-performing configuration.
Code
The official PyTorch implementation is available at twitter-research/tgn. TGN is also implemented in PyTorch Geometric, which makes it easy to use as a building block in other models.
Talks
Jun 2021
Machine Learning on Dynamic Graphs: Temporal Graph Networks MLOps World 2021
Apr 2021
Machine Learning on Dynamic Graphs: Temporal Graph Networks Intel ML Seminar
Multi-relational temporal graphs are powerful tools for modeling real-world data, capturing the evolving and interconnected nature of entities over time. Recently, many novel models are proposed for ML on such graphs intensifying the need for robust evaluation and standardized benchmark datasets. However, the availability of such resources remains scarce and evaluation faces added complexity due to reproducibility issues in experimental protocols. To address these challenges, we introduce Temporal Graph Benchmark 2.0 (TGB 2.0), a novel benchmarking framework tailored for evaluating methods for predicting future links on Temporal Knowledge Graphs and Temporal Heterogeneous Graphs with a focus on large-scale datasets, extending the Temporal Graph Benchmark. TGB 2.0 facilitates comprehensive evaluations by presenting eight novel datasets spanning five domains with up to 53 million edges. TGB 2.0 datasets are significantly larger than existing datasets in terms of number of nodes, edges, or timestamps. In addition, TGB 2.0 provides a reproducible and realistic evaluation pipeline for multi-relational temporal graphs. Through extensive experimentation, we observe that 1) leveraging edge-type information is crucial to obtain high performance, 2) simple heuristic baselines are often competitive with more complex methods, 3) most methods fail to run on our largest datasets, highlighting the need for research on more scalable methods.
@article{tgb2_gastinger_2024,title={TGB 2.0: A Benchmark for Learning on Temporal Knowledge Graphs and Heterogeneous Graphs},author={Gastinger, Julia and Huang, Shenyang and Galkin, Mikhail and Loghmani, Erfan and Parviz, Ali and Poursafaei, Farimah and Danovitch, Jacob and Rossi, Emanuele and Koutis, Ioannis and Stuckenschmidt, Heiner and Rabbany, Reihaneh and Rabusseau, Guillaume},year={2024},journal={Advances in Neural Information Processing Systems},volume={37},pages={140199-140229},arxiv={2406.09639},}
LoG
Conference
UTG: Towards a Unified View of Snapshot and Event Based Models for Temporal Graphs
Many real world graphs are inherently dynamic, constantly evolving with node and edge additions. These graphs can be represented by temporal graphs, either through a stream of edge events or a sequence of graph snapshots. Until now, the development of machine learning methods for both types has occurred largely in isolation, resulting in limited experimental comparison and theoretical crosspollination between the two. In this paper, we introduce Unified Temporal Graph (UTG), a framework that unifies snapshot-based and event-based machine learning models under a single umbrella, enabling models developed for one representation to be applied effectively to datasets of the other. We also propose a novel UTG training procedure to boost the performance of snapshot-based models in the streaming setting. We comprehensively evaluate both snapshot and event-based models across both types of temporal graphs on the temporal link prediction task. Our main findings are threefold: first, when combined with UTG training, snapshot-based models can perform competitively with event-based models such as TGN and GraphMixer even on event datasets. Second, snapshot-based models are at least an order of magnitude faster than most event-based models during inference. Third, while event-based methods such as NAT and DyGFormer outperforms snapshot-based methods on both types of temporal graphs, this is because they leverage joint neighborhood structural features thus emphasizing the potential to incorporate these features into snapshotbased models as well. These findings highlight the importance of comparing model architectures independent of the data format and suggest the potential of combining the efficiency of snapshot-based models with the performance of event-based models in the future.
@article{huang_utg_2024,title={UTG: Towards a Unified View of Snapshot and Event Based Models for Temporal Graphs},author={Huang, Shenyang and Poursafaei, Farimah and Rabbany, Reihaneh and Rabusseau, Guillaume and Rossi, Emanuele},year={2024},journal={Learning on Graphs Conference (LoG)},arxiv={2407.12269},}
2023
NeurIPS
Conference
Temporal Graph Benchmark for Machine Learning on Temporal Graphs
Shenyang Huang, Farimah Poursafaei, …, Emanuele Rossi, …, Reihaneh RabbanyShenyang Huang, Farimah Poursafaei, Jacob Danovitch, Matthias Fey, Weihua Hu, Emanuele Rossi, Jure Leskovec, Michael M. Bronstein, Guillaume Rabusseau, and Reihaneh Rabbany [show less]
Advances in Neural Information Processing Systems, 2023
We present the Temporal Graph Benchmark (TGB), a collection of challenging and diverse benchmark datasets for realistic, reproducible, and robust evaluation of machine learning models on temporal graphs. TGB datasets are of large scale, spanning years in duration, incorporate both node and edge-level prediction tasks and cover a diverse set of domains including social, trade, transaction, and transportation networks. For both tasks, we design evaluation protocols based on realistic use-cases. We extensively benchmark each dataset and find that the performance of common models can vary drastically across datasets. In addition, on dynamic node property prediction tasks, we show that simple methods often achieve superior performance compared to existing temporal graph models. We believe that these findings open up opportunities for future research on temporal graphs. Finally, TGB provides an automated machine learning pipeline for reproducible and accessible temporal graph research, including data loading, experiment setup and performance evaluation. TGB will be maintained and updated on a regular basis and welcomes community feedback. TGB datasets, data loaders, example codes, evaluation setup, and leaderboards are publicly available at this https URL.
@article{tgb_huang_2023,title={Temporal Graph Benchmark for Machine Learning on Temporal Graphs},author={Huang, Shenyang and Poursafaei, Farimah and Danovitch, Jacob and Fey, Matthias and Hu, Weihua and Rossi, Emanuele and Leskovec, Jure and Bronstein, Michael M. and Rabusseau, Guillaume and Rabbany, Reihaneh},year={2023},journal={Advances in Neural Information Processing Systems},arxiv={2307.01026},}
Citation
@article{rossi2020tgn,title={Temporal Graph Networks for Deep Learning on Dynamic Graphs},author={Emanuele Rossi and Ben Chamberlain and Fabrizio Frasca and Davide Eynard and Federico Monti and Michael Bronstein},journal={ICML Workshop on Graph Representation Learning},year={2020}}