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:
- 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.
- 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.
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.
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