STMemoLLM: A Spatial-Temporal Memory-Augmented LLM for Robust Traffic Forecasting
Organizations: Zhejiang University, Hangzhou, China. · Ant Group, Hangzhou, China. · Hunan University, Changsha, China.
Abstract
Traffic forecasting is essential for intelligent transportation systems. However, traditional deep-learning models often rely heavily on high-quality observations. Recent LLM-based approaches incorporate pretrained knowledge to improve forecasting, but they remain sensitive to input perturbations and struggle to preserve long-term patterns. To address this, we propose STMemoLLM, a spatial-temporal memory-augmented LLM for robust traffic forecasting. STMemoLLM introduces memory prototypes to compress inputs into compact summary tokens while extracting reliable dynamics from residual signals, achieving a balance between stability and variability. Specifically, a memory-enhanced tokenizer encodes prototypes and sensor characteristics into attention biases to guide adaptive compression of correlated sensors into semantic summary tokens. A memory-calibrated router further evaluates contextual deviation, compression deficiency, and prototype alignment to identify reliable residual signals, which complement the summaries while suppressing noise. Extensive experiments on eight real-world datasets show that STMemoLLM achieves state-of-the-art performance. Additional experiments examine point masking, additive Gaussian noise, structured missingness, and limited training data, demonstrating strong robustness. Code is available at https://anonymous.4open.science/r/STMemoLLM-70BF.
Figures & tables
| Dataset | #Nodes | Time Range | Granularity | Type |
|---|---|---|---|---|
| PEMS03 | 358 | 9/1/2018–11/30/2018 | 5 min | Traffic Flow |
| PEMS04 | 307 | 1/1/2018–2/28/2018 | 5 min | Traffic Flow |
| PEMS07 | 883 | 5/1/2017–8/31/2017 | 5 min | Traffic Flow |
| PEMS08 | 170 | 7/1/2016–8/31/2016 | 5 min | Traffic Flow |
| METR-LA | 207 | 3/1/2012–6/30/2012 | 5 min | Traffic Speed |
| PEMS-BAY | 325 | 1/1/2017–5/31/2017 | 5 min | Traffic Speed |
| Method | PEMS03 | PEMS04 | PEMS07 | PEMS08 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| MAE | RMSE | MAPE | MAE | RMSE | MAPE | MAE | RMSE | MAPE | MAE | RMSE | MAPE | |
| STGCN (2018) | 17.55 | 30.42 | 17.34 | 21.16 | 34.89 | 13.83 | 25.33 | 39.34 | 11.21 | 17.50 | 27.09 | 11.29 |
| ASTGCN (2019) | 17.34 | 29.56 | 17.21 | 22.93 | 35.22 | 16.56 | 24.01 | 37.87 | 10.73 | 18.25 | 28.06 | 11.64 |
| GWaveNet (2019) | 19.12 | 32.77 | 18.89 | 24.89 | 39.66 | 17.29 | 26.39 | 41.50 | 11.97 | 18.28 | 30.05 | 12.15 |
| AGCRN (2020) | 15.98 | 28.25 | 15.23 | 19.83 | 32.26 | 12.97 | 22.37 | 36.55 | 9.12 | 15.95 | 25.22 | 10.09 |
| MTGNN (2020) | 15.10 | 25.93 | 15.67 | 19.32 | 31.57 | 13.52 | 22.07 | 35.80 | 9.21 | 15.71 | 24.62 | 10.03 |
| Method | METR-LA | PEMS-BAY | NYCTaxi | CHBike | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Pick-up | Drop-off | Pick-up | Drop-off | |||||||||||||||
| Metric | MAE | RMSE | MAPE | MAE | RMSE | MAPE | MAE | RMSE | MAPE | MAE | RMSE | MAPE | MAE | RMSE | MAPE | MAE | RMSE | MAPE |
| STLLM (2024) | 3.13 ∗ | 6.37 ∗ | 8.54 ∗ | 1.60 ∗ | 3.58 ∗ | 3.67 ∗ | 5.29 | 9.42 | 35.41 | 5.07 | 9.07 | 34.59 | 2.07 | 3.23 | 58.93 | 1.91 | 2.83 | 51.71 |
| CrossST (2025) | 3.17 ∗ | 6.42 ∗ | 8.75 ∗ | 1.75 ∗ | 4.25 ∗ | 4.10 ∗ | 5.58 ∗ | 9.78 ∗ | 38.14 ∗ | 5.29 ∗ | 9.60 ∗ | 37.97 ∗ | 2.23 ∗ | 3.46 ∗ | 60.13 ∗ | 2.08 ∗ | 3.11 ∗ | 55.82 ∗ |
| STLLM+ (2025) | 3.17 ∗ | 6.48 ∗ | 8.66 ∗ | 1.68 ∗ | 3.71 ∗ | 3.77 ∗ | 5.18 | 8.98 | 33.22 | 4.94 | 8.68 | 36.09 | 1.98 | 3.05 | 55.59 | 1.89 | 2.79 | 51.48 |
| STD-PLM (2025) | 3.11 | 6.34 | 8.59 | 1.65 | 3.64 | 4.59 | 5.07 | 8.86 | 35.76 | 4.82 | 8.46 | 35.63 | 1.66 | 2.79 | 58.61 | 1.57 | 2.53 | 57.00 |
| Dataset | Metric | STD-PLM | STMemoLLM |
|---|---|---|---|
| PEMS03 | MAE | ||
| RMSE | |||
| MAPE (%) | |||
| PEMS04 | MAE | ||
| RMSE | |||
| MAPE (%) |
| Input condition | STMemoLLM | STD-PLM | MegaCRN |
|---|---|---|---|
| Clean | 18.01 | 18.15 | 18.52 |
| Point mask 5% | 20.15 (+11.9%) | 20.41 (+12.5%) | 20.61 (+11.3%) |
| Point mask 10% | 22.49 (+24.9%) | 22.89 (+26.1%) | 23.48 (+26.8%) |
| Point mask 20% | 27.70 (+53.9%) | 28.50 (+57.0%) | 33.04 (+78.4%) |
| Gaussian noise | 18.24 (+1.3%) | 18.42 (+1.5%) | 18.78 (+1.4%) |
| Gaussian noise | 18.81 (+4.5%) | 18.98 (+4.6%) | 19.47 (+5.1%) |
| Dataset | Sensor-level missing | Neighborhood-level missing | ||||
|---|---|---|---|---|---|---|
| Ratio | 5% | 10% | 20% | 1-hop | 2-hop | 3-hop |
| STD-PLM | 26.45 | 31.63 | 41.82 | 21.46 | 22.94 | 24.46 |
| STMemoLLM | 22.80 | 27.64 | 37.59 | 19.02 | 19.95 | 21.08 |
| Improv. | 13.80% | 12.59% | 10.12% | 11.38% | 13.04% | 13.80% |
| Dataset | PEMS03 | PEMS04 | PEMS07 | PEMS08 | ||||
|---|---|---|---|---|---|---|---|---|
| Ratio | 5% | 10% | 5% | 10% | 5% | 10% | 5% | 10% |
| STD-PLM | 22.52 | 17.08 | 27.73 | 25.11 | 32.48 | 26.37 | 22.56 | 19.72 |
| STMemoLLM | 20.64 | 16.33 | 26.03 | 22.83 | 27.38 | 23.79 | 21.66 | 18.90 |
| Improv. | 8.37% | 4.42% | 6.13% | 9.10% | 15.70% | 9.77% | 3.98% | 4.15% |
| Dataset | Full | w/o MCDR | w/o | w/o | w/o | Rand. |
|---|---|---|---|---|---|---|
| PEMS04 | ||||||
| PEMS08 |
| Dataset | Full | w/o | Topo. | Learn. | only | only |
|---|---|---|---|---|---|---|
| PEMS04 | ||||||
| PEMS08 |
| Dataset | Full | w/o | w/o | w/o both |
|---|---|---|---|---|
| PEMS04 | ||||
| PEMS08 |
| Method | Time (s/epoch) | Params (M) | Memory (GB) | MAE |
|---|---|---|---|---|
| DCRNN | 20.72 | 0.37 | 4.93 | 21.22 |
| STGCN | 1.83 | 0.39 | 0.80 | 21.16 |
| Graph WaveNet | 9.68 | 0.31 | 2.19 | 24.89 |
| MegaCRN | 67.08 | 0.39 | 4.91 | 18.78 |
| STLLM | 11.28 | 42.5 | 5.10 | 19.00 |
| TimeCMA | 75.40 | 29.4 | 21.63 | 21.79 |
Traffic Forecasting
Traffic forecasting predicts future flows, speeds, demand, travel times, and congestion from spatial, temporal, and contextual data.
See all 99 papers