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
Fig. 1: Overview of STMemoLLM
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
TABLE I: Dataset statistics.
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
TABLE II: Results on PEMS03/04/07/08.
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
TABLE III: Results on METR-LA, PEMS-BAY, NYCTaxi, and CHBike.
Dataset
Metric
STD-PLM
STMemoLLM
PEMS03
MAE
14.576±0.009
14.440±0.016†
RMSE
25.466±0.043
24.951±0.057†
MAPE (%)
14.938±0.011
14.666±0.023†
PEMS04
MAE
18.160±0.012
18.008±0.013†
RMSE
30.316±0.036
30.122±0.037†
MAPE (%)
11.928±0.033
11.700±0.024†
TABLE IV: Five-seed comparison between STD-PLM and STMemoLLM.
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 σ=0.05
18.24 (+1.3%)
18.42 (+1.5%)
18.78 (+1.4%)
Gaussian noise σ=0.10
18.81 (+4.5%)
18.98 (+4.6%)
19.47 (+5.1%)
TABLE V: MAE results under controlled corruption.
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%
TABLE VI: MAE results under missing settings.
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%
TABLE VII: MAE results under few-shot settings.
Dataset
Full
w/o MCDR
w/o γD
w/o γC
w/o γA
Rand. IF
PEMS04
18.012±0.008
18.096±0.005
18.076±0.005
18.146±0.009
18.052±0.004
18.096±0.005
PEMS08
13.170±0.007
13.248±0.011
13.244±0.005
13.220±0.007
13.252±0.011
13.242±0.004
TABLE VIII: MAE results for router ablations.
Dataset
Full
w/o B
Topo. B
Learn. B
only Bpos
only Bneg
PEMS04
18.012±0.008
18.234±0.009
18.134±0.017
18.064±0.019
18.028±0.008
18.026±0.011
PEMS08
13.170±0.007
13.292±0.004
13.340±0.000
13.228±0.004
13.242±0.013
13.260±0.000
TABLE IX: MAE results for preference-bias ablations.
Dataset
Full
w/o Lnce
w/o Ldir
w/o both
PEMS04
18.012±0.008
18.064±0.011
18.132±0.008
18.312±0.008
PEMS08
13.170±0.007
13.248±0.008
13.292±0.008
13.372±0.008
TABLE X: MAE results for loss ablations.
Fig. 2: MAE results of the hyperparameter study.
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
TABLE XI: MAE results of the efficiency study.
Fig. 3: Recurring-context organization on PEMS04. (a) Ratios of six-hour-shifted to weekly recurring pair distances; error bars show 95% anchor-day bootstrap intervals. (b) Relative changes in the summary separation gap after removing retrieval and in recurring-context assignment JS after removing the preference bias.
Fig. 4: Responses to energy-matched structured changes and i.i.d. noise on PEMS04. (a) Prediction drift on affected nodes. (b) Fraction of affected nodes routed to the detail path; the dashed line marks random routing. Error bars show 95% paired-case bootstrap intervals.
Fig. 5: Tail-regime evaluation on PEMS04. (a) MAE reductions relative to the summary-only output; error bars show 95% confidence intervals from 1,000 paired day-block bootstrap resamples. LA and HD denote low alignment and high deviation. (b) Routing rates and MAE reductions under router interventions on rare LA+HD node–windows.
Shenzhen Ubiquitous Data Enabling Key Lab Shenzhen International Graduate School, Tsinghua University, Shenzhen, China · School of Computer Science and Engineering University of Electronic Science and Technology of China, Chengdu, China
School of Mathematics, Southeast University, Nanjing 210096, China · School of Cyber Science and Engineering, Southeast University, Nanjing 210096, China · Jiangsu Province Center for Applied Mathematical Sciences, Nanjing 210096, China