arXiv:2610.19603cs.LGOct 2026

Manuscript Offprint

arXiv:2610.19603

Beyond Static Positional Encoding: Bayesian Time-aware Attention for Non-Stationary Long-term Time Series Forecasting

Xinjie Lan, Yunbo Mei, Leheng Zhou, Hao Qi

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.

1 Introduction

Long-term time series forecasting (LTSF) aims to predict future trajectories over extended horizons from historical observations (Chen et al., 2023). Transformers have emerged as a prominent architecture for LTSF largely because self-attention (Vaswani et al., 2017) enables the modeling of long-range temporal dependencies (Wen et al., 2022). However, real-world time series often exhibit non-stationarity (Kim et al., 2021), including evolving trends (Liu et al., 2025a), time-varying seasonality (Sun et al., 2026), and distribution shifts (Li et al., 2026). Such changes can alter which historical observations are informative for future prediction, making it challenging for Transformer-based models to capture temporal dependencies that vary across historical input windows.

Existing approaches to non-stationary forecasting broadly follow two strategies: normalization and architectural adaptation. First, normalization methods, such as RevIN (Kim et al., 2021), standardize historical input windows to mitigate shifts in marginal statistics and restore the original scale and location to the predictions. However, local statistical normalization may be insufficient to address distribution shifts (Li et al., 2026); even after normalization, windows with similar marginal statistics can exhibit different temporal dependence structures (Liu et al., 2026). Second, architectural approaches introduce specialized mechanisms to capture evolving temporal patterns, as exemplified by Non-stationary Transformer (Liu et al., 2022), TimeBridge (Liu et al., 2025a), and DTAF (Lu et al., 2026). While these approaches improve temporal modeling, architecture-specific designs can introduce additional complexity and limit their applicability across different Transformer backbones. These limitations motivate a broadly applicable mechanism that enables Transformers to adapt to changing temporal dependencies without extensive architectural changes.

Beyond these methodological advances, a fundamental question remains: how does a Transformer forecaster model changing temporal dependencies? Without positional information, canonical self-attention is permutation-equivariant (Zeng et al., 2023) and therefore cannot distinguish temporal positions from content alone. Positional encoding (PE) addresses this limitation by introducing information about token positions or relative distances (Shaw et al., 2018), enabling self-attention to account for temporal order. This motivates a more specific question: how does PE interact with self-attention to support forecasting when temporal dependencies vary across historical input windows? Answering this question can clarify the temporal modeling behavior of Transformers under non-stationarity and provide a principled foundation for designing adaptive positional mechanisms.

In this paper, we address this question from a Bayesian perspective. We first interpret position-aware self-attention as a Bayesian posterior over attended positions: content-only scaled dot-product attention defines a prior over historical keys, while PE provides temporal-evidence likelihood that updates this prior according to temporal relationships. Building on this interpretation, we derive a population-level evidence lower bound (ELBO) (Bishop, 2006) that characterizes the effect of PE on forecasting weakly-stationary time series. To extend the analysis to non-stationarity, we introduce a regime-conditioned weakly-stationary formulation and show that a static PE, which induces shared temporal evidence across input windows, can be strictly suboptimal when heterogeneous regimes induce incompatible regime-specific optima. This theoretical result motivates positional mechanisms that adapt their temporal evidence to each historical input window.

Motivated by our theoretical analysis, we propose Bayesian Time-aware Attention (BTA), a plug-and-play module that learns input-conditioned, head-specific temporal biases over relative lags. BTA aggregates attention scores by lag, augments them with Fourier features, and uses a mixture-of-experts (MoE) (Cai et al., 2025) router to combine periodic and non-periodic temporal kernels. This enables different heads and input windows to capture distinct local, periodic, and long-range dependencies. Extensive experiments show that BTA generalizes across conventional Transformers (Zhou et al., 2021; Nie et al., 2023) and time-series foundation models (Kottapalli et al., 2025), achieving competitive performance on non-stationary LTSF with high computational efficiency.

Our main contributions are summarized as follows:

• Theory. We interpret position-aware self-attention from a Bayesian perspective and derive a population-level ELBO that characterizes the role of PE in time-series forecasting, proving that static PE can be suboptimal under changing temporal dependencies.

• Methodology. We propose Bayesian Time-aware Attention (BTA), a plug-and-play module that learns input-conditioned, head-specific temporal biases through an MoE router combining complementary temporal kernels.

• Experiments. Extensive experiments across conventional Transformers and time-series foundation models demonstrate that BTA consistently improves non-stationary LTSF while maintaining computational efficiency.