Temporal Graph Networks for Deep Learning on Dynamic Graphs

Emanuele Rossi, Ben Chamberlain, Fabrizio Frasca, Davide Eynard, Federico Monti, Michael M. Bronstein

TL;DR

Temporal Graph Networks (TGNs) provide a generic, highly efficient framework for deep learning on continuous-time dynamic graphs. By combining a node-level memory module with graph-based neighborhood aggregation, TGNs achieve state-of-the-art accuracy on dynamic link prediction and node classification while operating up to 30x faster than previous attention-based methods.

What Problem Does This Paper Address?

Most Graph Neural Networks (GNNs) assume that the underlying graph structure is static. However, real-world networks—such as social networks, financial transaction logs, and biological interactomes—are inherently dynamic, with nodes and edges continuously appearing, disappearing, or changing over time.

Existing approaches for continuous-time dynamic graphs (CTDGs) generally fall into two sub-optimal categories:

  1. Recurrent-based models that update node states sequentially but lack GNN-like neighborhood aggregation, making them highly susceptible to "memory staleness" when a node is inactive for long periods.
  2. Pure graph-attention models that recompute embeddings from scratch using temporal neighborhoods, which is computationally expensive and fails to capture long-term historical dependencies.

TGN bridges this gap by unifying memory modules and graph-based operators into a single, computationally efficient framework.

Methods

TGN conceptualizes dynamic graph learning as an encoder-decoder problem. The core contribution is the TGN encoder, which processes continuous-time graphs represented as a sequence of timestamped events. It consists of several key modules:

  • Memory Module: Every node maintains a state vector ($s_i(t)$) that serves as a compressed representation of the node's entire historical trajectory.
  • Message Function & Aggregator: When an event occurs, messages are generated for the involved nodes. If multiple events hit the same node within a single batch, an aggregator (e.g., taking the most recent message or the mean) combines them.
  • Memory Updater: A recurrent network (such as a GRU or LSTM) updates the node's memory using the aggregated messages.
  • Embedding Module: To resolve memory staleness, a graph operator (like Temporal Graph Attention) aggregates the memories of a node's temporal neighbors. This ensures that even if a node has been inactive, its embedding is updated using the fresh context of its neighbors.

Preventing Information Leakage

A major challenge in training memory-based dynamic graph models is avoiding information leakage (i.e., using information from an interaction to update a node's memory before predicting that exact same interaction). TGN solves this with a novel training strategy utilizing a Raw Message Store, which delays memory updates to subsequent batches so that the memory modules can safely receive gradients during backpropagation.

Figure 2: Flow of operations of TGN used to train the memory-related modules. Raw Message Store stores the necessary raw information to compute messages, i.e. the input to the message functions, which we call raw messages, for interactions which have been processed by the model in the past. This allows the model to delay the memory update brought by an interaction to later batches. At first, the memory is updated using messages computed from raw messages stored in previous batches (1, 2, 3). The embeddings can then be computed using the just updated memory (grey link) (4). By doing this, the computation of the memory-related modules directly influences the loss (5, 6), and they receive a gradient. Finally, the raw messages for this batch interactions are stored in the raw message store (6) to be used in future batches.

Datasets

The authors evaluated TGN on three real-world datasets using a 70%-15%-15% chronological split:

  • Wikipedia: A bipartite graph of users editing pages (9,227 nodes, 157,474 edges), where dynamic labels indicate if a user was banned.
  • Reddit: A bipartite graph of users posting on subreddits (11,000 nodes, 672,447 edges).
  • Twitter: A non-bipartite retweet graph from the 2020 RecSys Challenge (8,861 nodes, 119,872 edges) utilizing BERT embeddings to represent retweet text.

Key Insights and Ideas

  • Graph Aggregation Cures Staleness: Memory modules are excellent for long-term dependencies, but graph aggregation is essential to keep inactive nodes up to date via their active neighbors.
  • One Layer is All You Need: While pure attention models like TGAT require multiple layers to perform well, TGN achieves state-of-the-art results with just one graph attention layer. Because the node memories already implicitly capture historical multi-hop context, TGN avoids deep neighborhood expansions, dramatically speeding up computation.
  • Recency Beats Uniformity: When sampling temporal neighbors for graph attention, selecting the most recent neighbors significantly outperforms uniform random sampling.

Key Results

  • State-of-the-Art Performance: TGN consistently outperforms all baselines in both transductive (predicting links between known nodes) and inductive (predicting links to completely unseen nodes) tasks. On the challenging Twitter dataset, TGN outperforms the second-best method (DyRep) by over 4% in transductive and 10% in inductive settings.
  • 30x Speedup: Due to its parallel batch processing and single-layer attention requirement, TGN runs up to 30 times faster per training epoch than pure attention-based baselines like TGAT.
Tradeoff between accuracy and speed

Limitations and Future Work

  • Simplistic Aggregators: For simplicity, the authors used non-learnable message aggregators (e.g., keeping only the most recent message). Implementing learnable aggregation functions is a clear next step.
  • No Global Context: The memory module is strictly node-specific. The authors suggest that incorporating a global, graph-wide memory to track macro-level network evolution could improve performance.
  • Limited Event Types in Evaluation: Although the TGN framework theoretically supports node/edge deletions and feature updates, the datasets used in the experiments only contained edge creation events. Further validation on more complex dynamic topologies is required.

Summary updated

BibTeX
@misc{rossi2020temporal,
  author = {Emanuele Rossi and Ben Chamberlain and Fabrizio Frasca and Davide Eynard and Federico Monti and Michael M. Bronstein},
  title = {{Temporal Graph Networks for Deep Learning on Dynamic Graphs}},
  year = {2020},
  eprint = {2006.10637},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2006.10637},
}
Figure