Manuscript Offprint
arXiv:2609.11314A Dynamic Fusion Large Language Model for Traffic Flow Prediction
Xue Qiu and Jianli Xiao (✉)
School of Optical-Electrical and Computer Engineering, University of Shanghai for Science and Technology, Shanghai, China
233370847@st.usst.edu.cn, audyxiao@sjtu.edu.cn
Abstract. Traffic flow prediction is a core supporting technology for intelligent transportation systems. It uses historical data to infer future traffic dynamics in specific areas, thereby helping to alleviate congestion and improve resource allocation efficiency. Traditional neural networks struggle to break through accuracy limits due to their reliance on singular feature modeling, while large language models (LLMs) suffer from insufficient capture of spatial topological information and mining spatiotemporal correlation. This study proposes a Dynamic Fusion Large Language Model (DF-LLM) for traffic flow prediction. The model incorporates three core components: spatiotemporal embedding module, spatiotemporal fusion module, and LLM backbone. The spatiotemporal embedding module enables synergistic representation of multi-scale spatiotemporal features. The spatiotemporal fusion module integrates spatial topology and dynamic dependencies via graph convolution. The LLM backbone adopts a differentiated parameter adaptation strategy to balance training efficiency and traffic data adaptability. Additionally, it introduces a context aggregation attention module to strengthens global dependencies. More importantly, the LLM backbone takes the residual connections to mitigate the gradient vanishing in deep networks. Experiments show that DF-LLM has achieved better performance by comparing the metrics on all the four datasets.
Keywords: Traffic Flow Prediction · Intelligent Transportation Systems · Large Language Models · Spatiotemporal Features · Dynamic Fusion
1 Introduction
Within intelligent transportation systems (ITS), traffic flow prediction plays a pivotal role, enabling accurate forecasting of future traffic conditions based on historical data. This capability is essential for advancing traffic management, alleviating congestion, and optimizing resource allocation .
While traditional time series models like ARIMA and Kalman Filtering can capture linear temporal trends, they struggle to model the complex spatiotemporal dependencies in traffic data. Convolutional neural networks (CNNs) and recurrent neural networks (RNNs) have been widely used to capture spatial and
Xue Qiu and Jianli Xiao
temporal dependencies [3]. Nevertheless, these models are fundamentally constrained by the irregular, non-Euclidean topology of traffic data and its multi-scale periodic patterns. Graph convolutional networks (GCNs) [4–7] have been introduced to explicitly address spatial structure in traffic networks, but they often suffer from over-smoothing, limiting their ability to capture global patterns. Attention-based models offer more flexibility but come with complex architectures and substantial computational overhead.
LLMs have achieved significant progress across multiple domains and are gradually being utilized in time series research. By leveraging extensive pretraining and massive parameter capacities, LLMs maintain structural stability while enhancing performance [8]. However, LLM-based approaches mainly focus on the temporal dimension, largely neglecting the rich spatial topology in traffic networks [9, 10]. Additionally, the structural and semantic disparities between language and traffic data hinder LLMs from effectively transferring knowledge, potentially compromising prediction performance.
To address these challenges, we propose DF-LLM, a unified spatiotemporal forecasting framework that integrates graph-based spatial modeling with a pretrained Transformer backbone for traffic flow prediction. The proposed framework incorporates a spatiotemporal fusion module with residual connections and a differentiated parameter adaptation strategy, enabling effective domain adaptation while preserving valuable pretrained knowledge. Extensive experiments demonstrate that DF-LLM achieves competitive or superior forecasting performance compared with existing advanced methods, highlighting its potential for intelligent transportation systems.
2.1 Spatiotemporal Embedding Module
The spatiotemporal embedding module, which is critical for extracting discriminative representations from historical traffic data, is composed of three parallel

LLM Backbone
Fig. 1. The framework of DF-LLM.
branches: initial feature embedding, temporal embedding, and spatial embedding.
Initial Feature Embedding. We first employ a pointwise convolution to the input data to extract basic features:
where denotes a convolution operation with kernel shape , and represents learnable parameters. This step generates an initial feature embedding .
Temporal Embedding. To capture periodic patterns inherent in traffic data, we introduce two learnable parameter matrices: and . We extract daily and weekly temporal indices and from the input data, then adopt absolute positional encoding to generate (daily resolution) and (weekly resolution), where and denote the number of time steps per day and per week, respectively. The temporal embedding is computed as:
Spatial Embedding. To model spatial topological correlations between road segments, we propose an adaptive spatial embedding mechanism:
Here, denotes a non-linear activation function, and the parameters and are learnable. This operation yields a spatial embedding that captures spatial topological dependencies.
The three embeddings , and are concatenated and fed into the subsequent spatiotemporal fusion module to achieve multi-scale spatiotemporal feature integration.
Xue Qiu and Jianli Xiao
2.2 Spatiotemporal Fusion Module
This module integrates and refines the embeddings generated by the spatiotemporal embedding module, and captures spatial topological relationships via dynamic graph convolutional operations.
Feature Fusion. By concatenating , , and along the feature dimension, we obtain . Subsequently, a convolution layer with residual connections projects this concatenated feature to the target dimension:
where denotes learnable parameters of the convolution kernel with a shape of , and is a linear projection of to match the output dimension of the convolution layer. Through residual connections, dimensionality reduction from to is achieved while preserving essential spatiotemporal features, mitigating the gradient vanishing problem and enhancing the stability of the training process.
Spatial Topological Modeling with Graph Convolutional Network. A two-layer GCN with residual connections is employed to to capture spatial topological dependencies. Given an adjacency matrix that characterizes the inherent connectivity of road segments, the GCN operations are defined as:
\mathbf{E}_{\mathrm{att}}=\mathrm{Softmax}\left(\mathrm{ReLU}\left(\mathrm{GCN}\left(\mathrm{ReLU}\left(\mathrm{GCN}(\mathbf{E}_{\mathrm{fused}},\mathbf{A};\theta_{\mathrm{gcn}1})\right),\mathbf{A};\theta_{\mathrm{gcn}2})\right)\right) \tag{5}where and denote learnable parameters of the two GCN layers, and the GCN operations are applied along the spatial dimension. This operation aggregates feature information from neighboring nodes based on spatial topological correlations, while the residual connection retains direct access to the original fused features. The output encapsulates rich multi-scale spatiotemporal information, serving as the input to the LLM Backbone.
2.3 LLM Backbone
In this study, GPT-2 is adopted as the LLM backbone for traffic flow prediction through selective parameter adaptation and architectural refinement. Its autoregressive Transformer architecture enables effective temporal dependency modeling while maintaining computational efficiency.
Differentiated Parameter Adaptation. As shown in Fig. 1, the K Transformer blocks of GPT-2 are divided into two subsets with different parameter update strategies. For the first U blocks, the multi-head self-attention (MHA) and feedforward (FF) layers are frozen to preserve pretrained knowledge, while layer normalization (LN) layers are trainable to adapt to traffic data distributions. For the remaining blocks, MHA layers are unfrozen to capture traffic spatiotemporal dependencies, whereas FF layers remain frozen to reduce overfitting. The input and output of GPT-2 are denoted as and , respectively.
Context Aggregation MHA Module. To enhance the adapted GPT-2 representations, we introduce a Context Aggregation MHA module to aggregate global spatiotemporal information. By dividing features into h parallel subspaces, this module captures multi-scale correlations and integrates residual connections with layer normalization:
where denotes the globally aggregated feature. The resulting representation combines pretrained knowledge with traffic-specific spatiotemporal patterns.
Traffic Flow Prediction. The generated representation is fed into a regression convolution layer to predict future traffic flows:
where represents predictions for the next time steps and denotes the learnable parameters.
3 Experiments and Results
3.1 Experimental Settings
Experiments are conducted on four public traffic datasets: PEMS04, PEMS08, METR-LA, and PEMS-BAY. Each dataset is split into training, validation, and test sets with a ratio of 6:2:2, and both historical and prediction horizons are set to 12 time steps. DF-LLM is implemented on the BasicTS [11] platform and trained on an NVIDIA GeForce RTX 4090 GPU using the Ranger21 optimizer with a learning rate of 0.0007. The LLM backbone contains six GPT-2 layers, with a batch size of 32 and 500 training epochs; early stopping is applied after 30 epochs without validation improvement. Performance is evaluated using MAE, RMSE, and MAPE, where lower values indicate better accuracy. DF-LLM is compared with representative deep learning methods, including DCRNN [12], STGCN [6], GWNet [5], STGODE [13], STID [14], AGCRN [4], STWave [15], STAEformer [16], DGCRN [7], and STNorm [17], as well as LLM-based methods such as ST-LLM [18] and GCNGPT [18].
3.2 Experimental Results
Main results. The performance comparisons on PEMS04, PEMS08, METR-LA, and PEMS-BAY are summarized in Table 1. Compared with deep learning and LLM-based baselines, DF-LLM achieves competitive forecasting performance across all datasets. On PEMS04, DF-LLM obtains 18.96 (MAE), 30.76 (RMSE),
Xue Qiu and Jianli Xiao
Table 1. Evaluation results of DF-LLM and baseline methods on four datasets.
| Model | PEMS04 | PEMS08 | METR-LA | PEMS-BAY | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| MAE | RMSE | MAPE | MAE | RMSE | MAPE | MAE | RMSE | MAPE | MAE | RMSE | MAPE | |
| DCRNN | 21.72 | 33.95 | 15.74% | 17.14 | 27.30 | 10.79% | 3.59 | 7.57 | 10.42% | 1.97 | 4.60 | 4.72% |
| STGCN | 21.60 | 33.83 | 14.73% | 18.25 | 28.55 | 11.73% | 3.71 | 7.57 | 10.30% | 2.07 | 4.70 | 4.78% |
| GWNet | 20.35 | 32.57 | 14.70% | 16.13 | 25.93 | 11.20% | 3.55 | 7.41 | 10.00% | 1.92 | 4.43 | 4.54% |
| STGODE | 21.06 | 33.31 | 15.24% | 17.13 | 26.98 | 11.30% | 3.61 | 7.53 | 11.11% | 1.98 | 4.48 | 4.66% |
| STID | 19.93 | 32.12 | 13.68% | 15.59 | 25.71 | 10.38% | 3.54 | 7.50 | 10.84% | 1.91 | 4.39 | 4.52% |
| AGCRN | 20.79 | 33.27 | 14.20% | 17.53 | 27.90 | 11.28% | 3.61 | 7.56 | 10.46% | 1.95 | 4.52 | 4.56% |
| STWave | 19.61 | 32.18 | 12.93% | 14.84 | 25.48 | 9.81% | 3.52 | 7.51 | 10.41% | 1.90 | 4.36 | 4.47% |
| STAEformer | 19.40 | 32.23 | 13.08% | 14.76 | 25.57 | 9.63% | 3.34 | 6.99 | 9.63% | 1.91 | 4.35 | 4.50% |
| DGCRN | 20.19 | 32.92 | 14.08% | 17.07 | 26.70 | 10.99% | 3.44 | 7.23 | 9.90% | 1.94 | 4.50 | 4.55% |
| STNorm | 20.46 | 34.20 | 13.68% | 16.97 | 27.52 | 10.77% | 3.57 | 7.49 | 10.43% | 1.94 | 4.50 | 4.64% |
| GCNGPT | 22.94 | 35.26 | 16.55% | 18.79 | 29.02 | 12.40% | 5.81 | 9.63 | 15.98% | 1.78 | 3.87 | 4.06% |
| ST-LLM | 19.74 | 31.31 | 13.81% | 15.76 | 24.67 | 10.05% | 3.28 | 6.65 | 8.79% | 1.67 | 3.72 | 3.70% |
| DF-LLM | 18.96 | 30.76 | 12.87% | 15.47 | 24.60 | 10.11% | 3.12 | 6.27 | 8.19% | 1.63 | 3.61 | 3.71% |

(a)
(b)
(c)
(d)
Fig. 2. Comparison of DF-LLM predictions with ground-truth values on four datasets: (a) PEMS04; (b) PEMS08; (c) METR-LA; (d) PEMS-BAY.
and 12.87% (MAPE), outperforming most baselines. On PEMS08, it achieves 24.60 (RMSE), demonstrating its ability to capture complex spatiotemporal patterns. For METR-LA, DF-LLM achieves 3.12 (MAE), 6.27 (RMSE), and 8.19% (MAPE), surpassing ST-LLM and GCNGPT. On PEMS-BAY, it reaches 1.63 (MAE) and 3.61 (RMSE), highlighting the effectiveness of integrating spatial and temporal information.
Multi-scenario adaptability analysis. To further evaluate the robustness of DF-LLM under diverse traffic conditions, visualization results are presented in Fig. 2. DF-LLM closely follows the ground truth across different datasets, accurately capturing short-term fluctuations and periodic patterns in PEMS04 and PEMS08, maintaining stable predictions under congested conditions in METR-LA, and modeling complex traffic dynamics in the large-scale PEMS-BAY dataset. Combined with the quantitative results in Table 1, these results demonstrate that DF-LLM adapts effectively to diverse traffic patterns and network scales.
Ablation study. Table 2 presents ablation results evaluating the contributions of Context Aggregation MHA, GCN, and residual connections (RC). Removing any component leads to performance degradation, while removing residual con-nections causes the most significant decline. These results verify the effectiveness of the proposed modules and highlight the importance of residual connections in stabilizing model training.
Table 2. Ablation study results.
| Model | PEMS04 | PEMS08 | METR-LA | PEMS-BAY | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| MAERMSE | MAPE | MAERMSE | MAPE | MAERMSE | MAPE | MAERMSE | MAPE | MAERMSE | MAPE | MAERMSE | MAPE | |
| No-MHA | 19.40 | 31.25 | 13.57% | 15.53 | 24.73 | 10.20% | 3.27 | 6.51 | 8.87% | 1.68 | 3.76 | 3.84% |
| No-GCN | 19.09 | 30.90 | 12.94% | 15.68 | 24.38 | 10.31% | 3.23 | 6.45 | 8.74% | 1.66 | 3.66 | 3.73% |
| No-RC | 22.39 | 36.35 | 15.33% | 19.02 | 30.34 | 12.72% | 3.36 | 6.70 | 9.02% | 2.09 | 4.35 | 4.71% |
| Ours | 18.96 | 30.76 | 12.87% | 15.47 | 24.60 | 10.11% | 3.12 | 6.27 | 8.19% | 1.63 | 3.61 | 3.71% |
4 Conclusion
This paper proposes DF-LLM, a traffic flow prediction framework that integrates graph convolution with a pretrained LLM backbone for spatiotemporal forecasting. By incorporating spatiotemporal embedding, graph-based spatial modeling, Context Aggregation MHA, and differentiated parameter adaptation, DF-LLM effectively captures complex traffic dynamics. Experiments on four real-world datasets demonstrate competitive forecasting performance compared with existing methods, while ablation studies validate the effectiveness of the proposed components. The model also exhibits stable adaptability across diverse traffic scenarios and network scales, underscoring its potential for intelligent transportation systems. Future work will explore dynamic spatiotemporal modeling and multimodal traffic data to further improve generalization and adaptability.
References
-
Lei, Z., Dong, Y., Li, J., Chen, C.: St-fit: Inductive spatial-temporal forecasting with limited training data. In: Proceedings of the AAAI Conference on Artificial Intelligence. vol. 39, pp. 12031–12039 (2025)
-
Huang, X., Dong, Y., Mao, J., Liao, J., Zhao, Y., Chen, S.: PTE-DHNet: Priority-aware temporal embedding and dynamic hypergraph network for steel transportation volume prediction. In: International Conference on Web Information Systems and Applications. pp. 15–28. Springer (2025)
-
Yuan, Z., Zhou, X., Yang, T.: Hetero-ConvLSTM: A deep learning approach to traffic accident prediction on heterogeneous spatio-temporal data. In: Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining. pp. 984–992 (2018)
-
Bai, L., Yao, L., Li, C., Wang, X., Wang, C.: Adaptive graph convolutional recurrent network for traffic forecasting. Advances in Neural Information Processing Systems 33, 17804–17815 (2020)
-
Wu, Z., Pan, S., Long, G., Jiang, J., Zhang, C.: Graph wavenet for deep spatial-temporal graph modeling. In: Proceedings of the 28th International Joint Conference on Artificial Intelligence. pp. 1907–1913 (2019)
Xue Qiu and Jianli Xiao
-
Yu, B., Yin, H., Zhu, Z.: Spatio-temporal graph convolutional networks: a deep learning framework for traffic forecasting. In: Proceedings of the 27th International Joint Conference on Artificial Intelligence. pp. 3634–3640 (2018)
-
Li, F., Feng, J., Yan, H., Jin, G., Yang, F., Sun, F., Jin, D., Li, Y.: Dynamic graph convolutional recurrent network for traffic prediction: Benchmark and solution. ACM Transactions on Knowledge Discovery from Data 17(1), 1–21 (2023)
-
Chen, Y., Wang, X., Xu, G.: GATGPT: A pre-trained large language model with graph attention network for spatiotemporal imputation. arXiv preprint arXiv:2311.14332 (2023)
-
Cao, D., Jia, F., Arik, S.O., Pfister, T., Zheng, Y., Ye, W., Liu, Y.: TEMPO: Prompt-based generative pre-trained transformer for time series forecasting. In: The Twelfth International Conference on Learning Representations (2024)
-
Zhou, T., Niu, P., Sun, L., Jin, R., et al.: One fits all: Power general time series analysis by pretrained LM. Advances in Neural Information Processing Systems 36, 43322–43355 (2023)
-
Shao, Z., Wang, F., Xu, Y., Wei, W., Yu, C., Zhang, Z., Yao, D., Sun, T., Jin, G., Cao, X., et al.: Exploring progress in multivariate time series forecasting: Comprehensive benchmarking and heterogeneity analysis. IEEE Transactions on Knowledge and Data Engineering 37(1), 291–305 (2025)
-
Li, Y., Yu, R., Shahabi, C., Liu, Y.: Diffusion convolutional recurrent neural network: Data-driven traffic forecasting. In: International Conference on Learning Representations (2018)
-
Fang, Z., Long, Q., Song, G., Xie, K.: Spatial-temporal graph ODE networks for traffic flow forecasting. In: Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining. pp. 364–373 (2021)
-
Shao, Z., Zhang, Z., Wang, F., Wei, W., Xu, Y.: Spatial-temporal identity: A simple yet effective baseline for multivariate time series forecasting. In: Proceedings of the 31st ACM International Conference on Information & Knowledge Management. pp. 4454–4458 (2022)
-
Fang, Y., Qin, Y., Luo, H., Zhao, F., Xu, B., Zeng, L., Wang, C.: When spatio-temporal meet wavelets: Disentangled traffic forecasting via efficient spectral graph attention networks. In: 2023 IEEE 39th International Conference on Data Engineering (ICDE). pp. 517–529. IEEE (2023)
-
Liu, H., Dong, Z., Jiang, R., Deng, J., Deng, J., Chen, Q., Song, X.: Spatio-temporal adaptive embedding makes vanilla transformer SOTA for traffic forecasting. In: Proceedings of the 32nd ACM International Conference on Information and Knowledge Management. pp. 4125–4129 (2023)
-
Deng, J., Chen, X., Jiang, R., Song, X., Tsang, I.W.: ST-Norm: Spatial and temporal normalization for multi-variate time series forecasting. In: Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining. pp. 269–278 (2021)
-
Liu, C., Yang, S., Xu, Q., Li, Z., Long, C., Li, Z., Zhao, R.: Spatial-temporal large language model for traffic prediction. In: 2024 25th IEEE International Conference on Mobile Data Management (MDM). pp. 31–40. IEEE (2024)