[Paper Review] TrafFormer: A Transformer Model for Predicting Long-term Traffic
TrafFormer proposes a novel Transformer-based model for long-term traffic prediction up to 24 hours in advance, overcoming limitations of recurrent models by using spatio-temporal multi-head attention and learnable time-day embeddings to capture complex temporal patterns. Experiments show it outperforms existing hybrid deep learning models across multiple metrics on METR-LA and PEMS-Bay datasets.
Traffic prediction is a flourishing research field due to its importance in human mobility in the urban space. Despite this, existing studies only focus on short-term prediction of up to few hours in advance, with most being up to one hour only. Long-term traffic prediction can enable more comprehensive, informed, and proactive measures against traffic congestion and is therefore an important task to explore. In this paper, we explore the task of long-term traffic prediction; where we predict traffic up to 24 hours in advance. We note the weaknesses of existing models--which are based on recurrent structures--for long-term traffic prediction and propose a modified Transformer model "TrafFormer". Experiments comparing our model with existing hybrid neural network models show the superiority of our model.
Motivation & Objective
- Address the research gap in long-term traffic prediction, as existing studies focus only on short-term forecasts (up to 1 hour).
- Overcome the instability of recurrent neural networks in long-horizon prediction due to error propagation.
- Develop a new deep learning architecture that captures short-, medium-, and long-term traffic patterns effectively.
- Propose a novel Transformer-based model, TrafFormer, with spatio-temporal multi-head attention and learnable time-day embeddings.
- Demonstrate superior performance on day-ahead traffic prediction compared to state-of-the-art hybrid neural network models.
Proposed method
- Introduce TrafFormer, a modified Transformer model designed specifically for long-term traffic prediction with a 24-hour horizon.
- Incorporate a spatio-temporal multi-head attention mechanism that models dependencies across different time steps and sensor locations.
- Use learnable time-day embeddings to encode temporal patterns across hours and days, capturing medium- and long-term trends.
- Replace recurrent structures with self-attention to avoid error accumulation over long sequences.
- Train the model end-to-end on historical traffic speed and flow data from loop detectors, using both past-hour and past-day data as input.
- Apply positional encoding adapted for cyclical time and day features to improve modeling of temporal periodicity.

Experimental results
Research questions
- RQ1Can a Transformer-based architecture outperform recurrent neural network-based models in long-term traffic prediction (up to 24 hours)?
- RQ2How effective are learnable time-day embeddings in capturing medium- and long-term traffic patterns compared to static cyclical features?
- RQ3What is the contribution of past-hour versus past-day data to long-term prediction accuracy?
- RQ4How does the spatio-temporal multi-head attention mechanism improve performance across multiple sensors and time steps?
- RQ5What components of the TrafFormer architecture are most critical for performance, as shown through ablation studies?
Key findings
- TrafFormer achieves the best overall performance across all evaluation metrics (RMSE, MAE, MAPE) on both METR-LA and PEMS-Bay datasets compared to baseline models.
- The ablation study confirms that time-day embeddings significantly improve performance, with performance dropping when replaced by cyclical features.
- Using only past-hour data (hour-only) leads to worse performance than using past-day data, indicating the importance of medium-term patterns.
- The day-only setting performs poorly due to large gaps (2 hours) in training sequences, which hinder learning and model stability.
- Speed-only input performs poorly, confirming that temporal and spatial context is essential for accurate long-term prediction.
- The spatio-temporal multi-head attention mechanism effectively models complex dependencies across sensors and time steps, contributing to superior generalization.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.