T-Graphormer: Using Transformers for Spatiotemporal Forecasting
Hao Yuan Bai, Xue Liu
TL;DR
This work introduces T-Graphormer, a Transformer-based framework that extends Graphormer with temporal encodings to model spatiotemporal dependencies jointly, mitigating the need for separate spatial and temporal modules. By incorporating centrality, learned temporal positions, and SPD-based spatial biases directly into the attention mechanism, it learns rich spacetime patterns from traffic graphs. Empirical results on standard traffic datasets show state-of-the-art performance with substantial RMSE/MAPE gains, and ablations highlight the critical role of positional and spatial encodings as well as special tokens. The approach offers a scalable, unified perspective on spatiotemporal forecasting, with potential extensions to dynamic graphs and more scalable attention mechanisms for large networks.
Abstract
Spatiotemporal data is ubiquitous, and forecasting it has important applications in many domains. However, its complex cross-component dependencies and non-linear temporal dynamics can be challenging for traditional techniques. Existing methods address this by learning the two dimensions separately. Here, we introduce Temporal Graphormer (T-Graphormer), a Transformer-based approach capable of modelling spatiotemporal correlations simultaneously. By adding temporal encodings in the Graphormer architecture, each node attends to all other tokens within the graph sequence, enabling the model to learn rich spacetime patterns with minimal predefined inductive biases. We show the effectiveness of T-Graphormer on real-world traffic prediction benchmark datasets. Compared to state-of-the-art methods, T-Graphormer reduces root mean squared error (RMSE) and mean absolute percentage error (MAPE) by up to 20% and 10%.
