Beyond Static Positional Encoding: Bayesian Time-aware Attention for Non-Stationary Long-term Time Series Forecasting
Organizations: Rice University · University of Hong Kong · University of North Carolina at Charlotte
Abstract
Transformers have demonstrated strong performance in long-term time series forecasting (LTSF), yet modeling non-stationary temporal dependencies remains challenging. In this paper, we interpret self-attention as a Bayesian posterior over attended positions, combining a content-based prior induced by scaled dot-product similarity with a temporal-evidence likelihood induced by positional encoding. This formulation provides a probabilistic interpretation of how positional encoding shapes the temporal dependencies captured by self-attention. Building on this perspective, we derive a population-level evidence lower bound (ELBO) that characterizes the role of positional encoding in forecasting weakly stationary time series. Our analysis further highlights a limitation of static positional encoding: when temporal dependence structures vary across input windows, a fixed temporal bias must accommodate heterogeneous dynamics and can therefore be suboptimal for non-stationary forecasting. Motivated by this analysis, we propose Bayesian Time-aware Attention (BTA), which employs a mixture-of-experts (MoE) router to adaptively combine temporal kernels and generate input-conditioned, head-specific positional biases. Extensive experiments on standard LTSF benchmarks demonstrate that BTA consistently improves forecasting performance across multiple Transformer backbones and achieves competitive overall performance with modest computational overhead and stable training.
Figures & tables
| Model | Informer ( Zhou et al., 2021 ) | PatchTST ( Nie et al., 2023 ) | Timer-XL ( Liu et al., 2025c ) | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Self-Attention | Vanilla | BTA | Gain(%) | Vanilla | BTA | Gain(%) | Vanilla | BTA | Gain(%) | ||||||||||
| Data | ADF | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE |
| ETTh1 | -5.91 | 1.096 | 0.835 | 0.981 | 0.769 | 10.50 | 7.88 | 0.516 | 0.477 | 0.425 | 0.429 | 17.51 | 10.02 | 0.409 | 0.430 | 0.379 | 0.407 | 7.28 | 5.35 |
| ETTm1 | -14.98 | 0.826 | 0.690 | 0.756 | 0.652 | 8.47 | 5.47 | 0.406 | 0.408 | 0.371 | 0.395 | 8.80 | 3.07 | 0.360 | 0.383 | 0.353 | 0.380 | 1.74 | 0.65 |
| Weather | -26.68 | 0.463 | 0.459 | 0.398 | 0.424 | 14.05 | 7.73 | 0.265 | 0.286 | 0.254 | 0.278 | 4.34 | 2.80 | 0.240 | 0.273 | 0.235 | 0.266 | 1.98 | 2.48 |
| Solar | -37.23 | 0.233 | 0.268 | 0.220 | 0.261 | 5.79 | 2.89 | 0.270 | 0.307 | 0.241 | 0.272 | 10.74 | 11.48 | 0.218 | 0.247 | 0.193 | 0.242 | 11.80 | 2.22 |
| Model | Ours | PULSE | DTAF | DUET | TimeBridge | iTransformer | TimeMixer | PatchTST | TimesNet | DLinear | Stationary | |||||||||||
| Liu et al. (2026) | Lu et al. (2026) | Qiu et al. (2025) | Liu et al. (2025a) | Liu et al. (2024) | Wang et al. (2024) | Nie et al. (2023) | Wu et al. (2023) | Zeng et al. (2023) | Liu et al. (2022) | |||||||||||||
| Metric | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE |
| ETTh1 | 0.394 | 0.423 | 0.412 | 0.422 | 0.416 | 0.435 | 0.404 | 0.427 | 0.399 | 0.426 | 0.439 | 0.448 | 0.427 | 0.441 | 0.413 | 0.434 | 0.488 | 0.452 | 0.423 | 0.437 | 0.644 | 0.554 |
| ETTh2 | 0.338 | 0.382 | 0.361 | 0.391 | 0.363 | 0.396 | 0.344 | 0.390 | 0.344 | 0.384 | 0.374 | 0.406 | 0.349 | 0.397 | 0.351 | 0.395 | 0.414 | 0.427 | 0.431 | 0.447 | 0.521 | 0.487 |
| ETTm1 | 0.337 | 0.371 | 0.363 | 0.388 | 0.338 | 0.368 | 0.336 | 0.370 | 0.348 | 0.379 | 0.362 | 0.391 | 0.356 | 0.380 | 0.353 | 0.381 | 0.399 | 0.406 | 0.357 | 0.379 | 0.527 | 0.472 |
| ETTm2 | 0.246 | 0.305 | 0.262 | 0.314 | 0.249 | 0.307 | 0.255 | 0.316 | 0.250 | 0.307 | 0.269 | 0.329 | 0.257 | 0.318 | 0.256 | 0.317 | 0.314 | 0.333 | 0.267 | 0.332 | 0.567 | 0.462 |
| Attention | Self-attention | Bayesian Time-aware Attention | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Optimization | Static | Static | MoE (TE) | MoE (TE + Fourier) | |||||||
| Kernels | None | Local | Local + periodic | Local + periodic | Local + periodic | ||||||
| Dataset | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | |
| Solar | 96 | 0.161 | 0.224 | 0.158 | 0.219 | 0.157 | 0.213 | 0.152 | 0.201 | 0.150 | 0.198 |
| 192 | 0.177 | 0.237 | 0.176 | 0.225 | 0.176 | 0.219 | 0.173 | 0.214 | 0.171 | 0.211 | |
| 336 | 0.196 | 0.232 | 0.192 | 0.230 | 0.191 | 0.227 | 0.187 | 0.227 | 0.184 | 0.226 | |
Appendix figures & tables19 assets
Supplementary material from the paper’s appendix.
Appendix
| PE method | Domain | ||
|---|---|---|---|
| Gaussian/RBF | NLP | ||
| ALiBi | NLP | ||
| KERPLE | NLP | ||
| Powerformer | TSF | ||
| RoPE | NLP & TSF | — |
| PE Method | Best epoch | Val. MSE | Test MSE | Smooth MSE | Periodic MSE |
|---|---|---|---|---|---|
| RPE | 30 | 0.2578 | 0.2337 | 0.1792 | 0.2882 |
| RoPE | 30 | 0.2364 | 0.2124 | 0.1354 | 0.2893 |
| ALiBi | 30 | 0.2573 | 0.2336 | 0.1801 | 0.2871 |
| BTA | 30 | 0.2049 | 0.1788 | 0.0993 | 0.2583 |
| PE | Test MSE | Expected log likelihood | Mean KL | ELBO |
|---|---|---|---|---|
| RPE | 0.2337 | 348.0968 | ||
| ALiBi | 0.2336 | 271.2189 | ||
| RoPE | 0.2124 | 51.4227 | ||
| BTA | 0.1788 | 46.6581 |
| Dataset | Training | Validation | Testing | Interval | ADF stat. | |
|---|---|---|---|---|---|---|
| ETTh1 | 7 | 8,545 | 2,881 | 2,881 | 1 hour | |
| ETTh2 | 7 | 8,545 | 2,881 | 2,881 | 1 hour | |
| ETTm1 | 7 | 34,465 | 11,521 | 11,521 | 15 min | |
| ETTm2 | 7 | 34,465 | 11,521 | 11,521 | 15 min | |
| Electricity | 321 | 18,317 | 2,633 | 5,261 | 1 hour | |
| Traffic | 862 | 12,185 | 1,757 | 3,509 | 1 hour |
| Backbone | Informer ( Zhou et al., 2021 ) | PatchTST ( Nie et al., 2023 ) | TimeBridge ( Liu et al., 2025a ) | Timer-XL ( Liu et al., 2025c ) |
|---|---|---|---|---|
| Representative role | Early LTSF Transformer | Patch-based Transformer | Non-stationary Transformer | Pretrained TSFM |
| Architecture | Encoder–decoder | Encoder-only | Encoder-only | Decoder-only |
| Attention design | ProbSparse | Self-attention | Integrated + PatchDownsampling + Cointegrated | Causal TimeAttention |
| Tokenization | Point-wise | Patch-wise | Patch-wise | Patch-wise |
| Positional mechanism | Sinusoidal absolute PE | Learnable absolute PE | None | Rotary PE + variable bias |
| Training paradigm | Task-specific | Task-specific | Task-specific | Pretraining / task-specific |
| Configuration | Informer | PatchTST | TimeBridge | Timer-XL |
|---|---|---|---|---|
| Token level | Point-wise | Patch-wise | Patch-wise | Patch-wise |
| Sequence length | 96 | 96 | 720 | 672 |
| Patch length | 1 | 16 | 24 or 48 | 96 |
| Input tokens | 96 | 12 | 30 or 15 | 7 |
| Lag unit | Time step | Patch | Patch | Patch |
| Kernel families | RBF + Periodic | RBF + Periodic | RBF + Periodic | RBF + Periodic |
| Model | Informer ( Zhou et al., 2021 ) | PatchTST ( Nie et al., 2023 ) | Timer-XL ( Liu et al., 2025c ) | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Self-Attention | Vanilla | BTA | Gain (%) | Vanilla | BTA | Gain (%) | Vanilla | BTA | Gain (%) | ||||||||||
| Dataset | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | |
| ETTh1 | 96 | 0.992 | 0.785 | 0.878 | 0.719 | 11.49 | 8.41 | 0.460 | 0.447 | 0.367 | 0.394 | 20.22 | 11.86 | 0.364 | 0.397 | 0.343 | 0.379 | 5.77 | 4.53 |
| 192 | 1.008 | 0.801 | 0.895 | 0.726 | 11.21 | 9.36 | 0.512 | 0.447 | 0.423 | 0.425 | 17.38 | 4.92 | 0.405 | 0.424 | 0.376 | 0.402 | 7.16 | 5.19 | |
| 336 | 1.179 | 0.870 | 1.038 | 0.793 | 11.96 | 8.85 | 0.546 | 0.496 | 0.441 | 0.436 | 19.23 | 12.10 | 0.427 | 0.439 | 0.391 | 0.413 | 8.43 | 5.92 | |
| 720 | 1.204 | 0.882 | 1.112 | 0.837 | 7.64 | 5.10 | 0.544 | 0.517 | 0.470 | 0.461 | 13.60 | 10.83 | 0.439 | 0.459 | 0.406 | 0.433 | 7.52 | 5.66 | |
| Model | Informer ( Zhou et al., 2021 ) | PatchTST ( Nie et al., 2023 ) | Timer-XL ( Liu et al., 2025c ) | ||||
|---|---|---|---|---|---|---|---|
| Dataset | Horizon | Vanilla MSE | BTA MSE | Vanilla MSE | BTA MSE | Vanilla MSE | BTA MSE |
| ETTh1 | 96 | ||||||
| 192 | |||||||
| 336 | |||||||
| 720 | |||||||
| ETTm1 | 96 | ||||||
| Model | Ours | PULSE | DTAF | DUET | TimeBridge | iTransformer | TimeMixer | PatchTST | TimesNet | DLinear | Stationary | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ( Liu et al., 2026 ) | ( Lu et al., 2026 ) | ( Qiu et al., 2025 ) | ( Liu et al., 2025a ) | ( Liu et al., 2024 ) | ( Wang et al., 2024 ) | ( Nie et al., 2023 ) | ( Wu et al., 2023 ) | ( Zeng et al., 2023 ) | ( Liu et al., 2022 ) | ||||||||||||||
| Metric | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | |
| ETTm1 | 96 | 0.275 | 0.330 | 0.303 | 0.347 | 0.277 | 0.329 | 0.279 | 0.336 | 0.284 | 0.337 | 0.300 | 0.353 | 0.293 | 0.345 | 0.293 | 0.346 | 0.338 | 0.375 | 0.299 | 0.343 | 0.393 | 0.404 |
| 192 | 0.315 | 0.359 | 0.349 | 0.379 | 0.329 | 0.361 | 0.318 | 0.359 | 0.323 | 0.365 | 0.345 | 0.382 | 0.335 | 0.372 | 0.333 | 0.370 | 0.371 | 0.387 | 0.335 | 0.365 | 0.481 | 0.447 | |
| 336 | 0.351 | 0.385 | 0.375 | 0.398 | 0.345 | 0.374 | 0.345 | 0.378 | 0.370 | 0.394 | 0.374 | 0.398 | 0.368 | 0.386 | 0.369 | 0.390 | 0.410 | 0.411 | 0.369 | 0.386 | 0.555 | 0.489 | |
| 720 | 0.408 | 0.411 | 0.424 | 0.426 | 0.399 | 0.407 | 0.400 | 0.408 | 0.415 | 0.418 | 0.429 | 0.430 | 0.426 | 0.417 | 0.416 | 0.420 | 0.478 | 0.450 | 0.425 | 0.421 | 0.677 | 0.548 | |
| Model | Ours | TimeBridge | DUET | DTAF | |||||
|---|---|---|---|---|---|---|---|---|---|
| Liu et al. (2025a) | Qiu et al. (2025) | Lu et al. (2026) | |||||||
| Metric | FLOPs | Size | FLOPs | Size | FLOPs | Size | FLOPs | Size | |
| ETTh1 | 96 | 274.9M | 0.786M | 274.6M | 0.772M | 35.7M | 3.605M | 19.0M | 0.582M |
| 192 | 280.0M | 1.155M | 279.7M | 1.141M | 46.7M | 5.132M | 26.8M | 1.121M | |
| 336 | 287.8M | 1.708M | 287.5M | 1.693M | 65.4M | 5.730M | 38.4M | 1.964M | |
| 720 | 308.4M | 3.182M | 308.1M | 3.168M | 72.6M | 6.981M | 69.4M | 4.176M | |
| Attention | Self-attention | Bayesian Time-aware Attention | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Optimization | Static | Static | MoE (TE only) | MoE (TE+Fourier) | |||||||
| Kernels | None | Local | Local+Periodic | Local+Periodic | Local+Periodic | ||||||
| Metric | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | |
| Weather | 96 | 0.313 | 0.375 | 0.274 | 0.353 | 0.270 | 0.348 | 0.266 | 0.339 | 0.253 | 0.335 |
| 192 | 0.377 | 0.408 | 0.333 | 0.394 | 0.320 | 0.384 | 0.313 | 0.377 | 0.299 | 0.369 | |
| 336 | 0.448 | 0.449 | 0.467 | 0.458 | 0.460 | 0.457 | 0.412 | 0.428 | 0.389 | 0.413 | |