Abstract
Temporal Graph Neural Networks have garnered substantial attention for their capacity to model evolving structural and temporal patterns while exhibiting impressive performance. However, it is known that these architectures are encumbered by issues that constrain their performance, such as over-squashing and over-smoothing. Meanwhile, Transformers have demonstrated exceptional computational capacity to effectively address challenges related to long-range dependencies. Consequently, we introduce Todyformer—a novel Transformer-based neural network tailored for dynamic graphs. It unifies the local encoding capacity of Message-Passing Neural Networks (MPNNs) with the global encoding of Transformers through i) a novel patchifying paradigm for dynamic graphs to improve over-squashing, ii) a structure-aware parametric tokenization strategy leveraging MPNNs, iii) a Transformer with temporal positional-encoding to capture long-range dependencies, and iv) an encoding architecture that alternates between local and global contextualization, mitigating over-smoothing in MPNNs. Experimental evaluations on public benchmark datasets demonstrate that Todyformer consistently outperforms the state-of-the-art methods for downstream tasks. Furthermore, we illustrate the underlying aspects of the proposed model in effectively capturing extensive temporal dependencies in dynamic graphs.
Introduction
Dynamic graphs, where nodes and edges evolve over time, are ubiquitous in real-world applications such as social networks and financial transaction systems. Traditionally, researchers have relied on Message-Passing Neural Networks (MPNNs) to model these structures. However, MPNNs face two major hurdles: over-smoothing, where node embeddings converge into uninformative representations as layers are added, and over-squashing, where the compression of information from an exponentially growing neighborhood into a fixed-size vector creates a massive information bottleneck.
While Transformers excel at capturing long-range dependencies in sequential data, adapting them to dynamic graphs is non-trivial because graphs lack a natural "patch" structure. Todyformer bridges this gap by creating a holistic encoder that handles both local structure and global history through a hybrid architecture.
Methodology
Todyformer introduces a novel architecture that alternates between local structural encoding and global temporal reasoning.
Temporal Patchifying and Tokenization
Inspired by Vision Transformers (ViT), the model divides the input graph into $M$ non-overlapping temporal subgraphs, or "patches." Each patch contains an equal number of edges, breaking a complex history into manageable chunks to mitigate over-squashing. Instead of feeding raw nodes into a Transformer, Todyformer uses a dynamic GNN (specifically DyG2Vec) to encode each patch. This Structure-Aware Tokenization ensures that the tokens processed by the Transformer already contain rich local structural and temporal information.
Alternating Local-Global Architecture
The core of Todyformer is an alternating sequence of local (GNN) and global (Transformer) encoders. A specialized Node Packing/Unpacking module collects embeddings for nodes that appear in multiple patches and arranges them into sequences. This allows the Transformer to look across the entire "timeline" of a specific node’s interactions. This design effectively allows the Transformer to act as a global contextualizer that "refreshes" embeddings, enabling the model to go deeper than traditional GNNs without suffering from over-smoothing.
Experimental Evaluation
The authors evaluated Todyformer on a wide array of benchmarks, including standard datasets like MOOC and LastFM, as well as the more challenging Temporal Graph Benchmark (TGBL) suite.
Performance on Large-Scale Datasets
Todyformer consistently ranked 1st or 2nd across almost all datasets for both Future Link Prediction (FLP) and Dynamic Node Classification (DNC). On the TGBL-Comment dataset, Todyformer demonstrated remarkable dominance, outperforming the next best model by a staggering 39% in Mean Reciprocal Rank (MRR).
Efficiency and Resilience
Despite the complexity of Transformer blocks, Todyformer remains significantly faster and lighter than random-walk-based methods like CAW. Furthermore, while pure MPNNs typically see performance drops after a few layers due to over-smoothing, Todyformer’s performance actually increases as more alternating blocks are added, proving its resilience to depth.
Conclusion
Todyformer represents a significant advancement in dynamic graph modeling by unifying the strengths of MPNNs and Transformers. By isolating message-passing within temporal patches and using Transformers for global contextualization, it effectively addresses the long-standing issues of over-squashing and over-smoothing. Future work may involve incorporating global structural biases, such as Laplacian Positional Encodings, to further enhance the model's expressive power.
Summary updated