A Cloud-Based Spatio-Temporal GNN-Transformer Hybrid Model for Traffic Flow Forecasting with External Feature Integration

Zhuo Zheng, Lingran Meng, Ziyu LinarXiv 2025 · DOI · arXiv

Introduction

Accurate traffic forecasting is a cornerstone of Intelligent Transportation Systems (ITS). By predicting bottlenecks before they manifest, city planners can optimize signal timings and reroute traffic, potentially saving thousands of hours in lost productivity. However, traffic dynamics are governed by complex spatio-temporal dependencies and external variables, making them difficult to model with traditional linear or simple recurrent approaches.

Problem Statement

Traffic forecasting presents two primary challenges:

  1. Spatial Dependencies: Road segments are interconnected; congestion at one intersection naturally propagates to its neighbors. Traditional models often fail to capture this graph-like topology.
  2. Temporal Dependencies: Traffic patterns exhibit both short-term fluctuations and long-term periodicities (e.g., weekly cycles). Standard recurrent networks like LSTMs often struggle with long-range dependencies.

Furthermore, external factors such as weather conditions and accidents significantly impact flow, yet are frequently omitted from predictive models.

Methodology

The proposed hybrid architecture integrates Graph Neural Networks (GNNs) for spatial modeling and Transformers for temporal modeling, deployed within a cloud-native environment.

Architecture of the proposed cloud-based GNN-Transformer hybrid model.

Spatial and Temporal Modeling

The model treats the urban road network as a directed graph. A GNN layer employs graph convolutions to learn spatial features from neighboring nodes. These features are then passed to a Transformer module. Unlike recurrent units, the Transformer’s self-attention mechanism processes all historical time steps in parallel, effectively capturing long-term periodic patterns.

Feature Fusion and Cloud Deployment

External data—including weather metrics (temperature, rainfall, visibility) and incident logs—are embedded into vectors and fused with the spatio-temporal features. The entire pipeline is designed for cloud scalability, utilizing HDFS/S3 for data storage and Kubernetes for real-time inference across hundreds of intersections.

Experimental Results

The model was evaluated using a real-world dataset comprising over 5 million records from 300 major intersections over a six-month period. Training performance demonstrated steady convergence, reaching a stable loss level of approximately 8.5.

Training and validation loss curves showing model convergence.

The hybrid model was tested against several deep learning baselines:

Model MAE RMSE $R^2$
LSTM (Baseline) 18.62 26.47 0.71
TCN 14.27 22.05 0.82
Transformer Only 12.72 20.16 0.86
GNN-Transformer (Proposed) 10.53 17.92 0.90

The proposed model achieved an $R^2$ of 0.90, significantly outperforming the "Transformer only" approach and proving that spatial graph information is vital for accuracy. This represents a 43% improvement in MAE over the standard LSTM baseline.

Conclusion

The integration of GNNs and Transformers provides a holistic view of urban traffic, successfully capturing both "where" and "when" congestion occurs. While the model shows high accuracy, future work will focus on improving performance during extreme "black-swan" events and integrating unstructured data sources like real-time video feeds.

Summary updated

BibTeX
@misc{zheng2025cloud,
  author = {Zhuo Zheng and Lingran Meng and Ziyu Lin},
  title = {{A Cloud-Based Spatio-Temporal GNN-Transformer Hybrid Model for Traffic Flow Forecasting with External Feature Integration}},
  year = {2025},
  eprint = {2510.27039},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.27039},
}
Figure