Introduction
Dynamic graphs, where nodes and edges evolve over time, are fundamental to modeling real-world systems such as social networks, recommendation engines, and fraud detection. Traditionally, representation learning on these graphs has relied on a hybrid "GNN+RNN" architecture. In this paradigm, Graph Neural Networks (GNNs) capture the spatial topology of discrete snapshots, while Recurrent Neural Networks (RNNs) track temporal evolution.
However, this approach faces significant bottlenecks. GNNs are prone to over-smoothing, where node representations become indistinguishable as depth increases. RNNs struggle with temporal decay and vanishing gradients, making long-term dependencies difficult to capture. Furthermore, snapshot-based methods are resource-intensive, often leading to Out-of-Memory (OOM) errors on large-scale datasets. Finally, most existing methods model nodes in isolation, failing to account for "behavior intersections"—the shared historical patterns between two nodes involved in a potential link.
DTFormer (Discrete-Time Transformer) addresses these challenges by abandoning the GNN+RNN stack in favor of a pure Transformer-based architecture that treats dynamic graph learning as a sequence modeling task.
Methodology
DTFormer re-imagines the dynamic graph problem by focusing on historical neighbor sequences rather than global graph snapshots. The architecture consists of three primary components: Feature Formatting, a Multi-Patching Module, and a Transformer Encoder.
1. Feature Formatting
Instead of processing the entire graph, DTFormer constructs sequences based on a node's historical first-hop neighbors. To provide the model with a rich context, it extracts five distinct feature types:
- Node & Edge Features: Standard attribute data.
- Positional Features: Time-encoded indices representing the snapshot order.
- Occurrence Features: Metrics tracking how frequently a specific neighbor appears.
- Intersect Features: A novel metric that tracks the interaction history of a neighbor node relative to both nodes in a potential link. This explicitly models the shared context between node pairs.
2. Multi-Patching Module
Inspired by the success of Vision Transformers (ViT), DTFormer introduces a multi-patching module. This module segments neighbor sequences into patches of varying sizes (e.g., 2, 4, and 8). This design allows the model to concurrently capture fine-grained local dynamics and broader global trends. By reducing the sequence length processed by the Transformer, this module also significantly lowers memory overhead.
3. Transformer Encoder
The patched sequences are processed by a Transformer encoder. Unlike RNNs, the Transformer’s self-attention mechanism allows it to weigh the importance of historical interactions regardless of their temporal distance. This effectively mitigates the "forgetting" problem inherent in recurrent architectures.
Experimental Results
DTFormer was evaluated against several state-of-the-art baselines, including ROLAND, EvolveGCN, and TGCN, across six diverse datasets: Bitcoin-OTC, UCI-Message, Reddit-Title, Reddit-Body, Mathoverstack, and Email-Eu-core.
Performance Gains
DTFormer achieved superior performance in Mean Reciprocal Rank (MRR) across all datasets. Notable improvements include:
- Email-Eu-core: A 134.18% improvement over the best-performing baseline.
- Mathoverstack: A 100.41% improvement in MRR.
Scalability and Efficiency
One of the most significant advantages of DTFormer is its memory efficiency. While snapshot-based models like GCRN frequently encountered OOM errors on larger datasets like Reddit-Title, DTFormer’s sequence-based approach allowed it to handle these datasets with ease. Ablation studies confirmed that the Neighbor Intersect Feature and the Multi-patching module were the primary contributors to the model's predictive accuracy.
Discussion and Key Insights
- The Power of Intersection: The Neighbor Intersect Feature proved critical. By explicitly encoding whether a neighbor is shared or appears in similar contexts for both nodes in a query, the model gains a massive boost in link prediction accuracy.
- Efficiency through Sequence Modeling: By moving away from snapshot-based GNNs, DTFormer avoids the need to store entire graph topologies in GPU memory. It only requires the specific neighbor sequences for the nodes being queried, making it highly scalable for large-scale industrial applications.
- Multi-Scale Temporal Awareness: The multi-patching module acts as a multi-scale lens, enabling the model to detect both "bursty" short-term behaviors and long-term cyclical patterns simultaneously.
Limitations and Future Work
While DTFormer represents a significant step forward, several areas for improvement remain. Currently, the model is constrained to first-hop neighbors; future work could explore incorporating higher-order neighborhood information through techniques like temporal random walks. Additionally, while memory-efficient, the complexity of intersection modeling can increase computation time. Finally, the optimal patch sizes are currently dataset-dependent, suggesting that automated architecture search could further optimize the model's performance across different domains.
Summary updated