This paper introduces SAMformer, a lightweight, shallow transformer architecture that finally enables these powerful models to outperform simple linear baselines in long-term time series forecasting. By combining channel-wise attention with Sharpness-Aware Minimization (SAM), it overcomes the training instabilities and "entropy collapse" that have historically hindered transformers in this domain.
What Problem Does This Paper Address?
Despite their dominance in natural language processing and computer vision, Transformers have surprisingly struggled with multivariate long-term time series forecasting. They often lose out to simple linear models or MLP-based architectures like TSMixer.
The authors investigate why this happens. Using a toy linear forecasting problem, they demonstrate that standard transformers fail to converge to optimal solutions even when the underlying data generation is simple. They pinpoint two primary failure modes:
- Entropy Collapse: Attention matrices quickly become identity-like during training, meaning the model stops learning useful feature interactions.
- Sharp Loss Landscapes: Transformers tend to converge to very "sharp" local minima, which leads to poor generalization on unseen data.
Methods
The authors propose SAMformer, a streamlined architecture designed to address these specific weaknesses. Its key components include:
- Shallow Architecture: A single-layer transformer encoder, which reduces complexity and overfitting risk.
- Channel-Wise Attention: Unlike standard temporal attention that looks at relationships between time steps ($L \times L$), SAMformer uses channel-wise attention to model correlations between different features or variables ($D \times D$). This is both more relevant for many forecasting tasks and computationally cheaper since the number of features $D$ is typically much smaller than the sequence length $L$.
- Sharpness-Aware Minimization (SAM): This is the critical optimization step. Instead of just minimizing training loss, SAM seeks out "flat" regions in the loss landscape. This prevents the model from getting stuck in the sharp, poorly-generalizing local minima typical of standard transformer training.
- Reversible Instance Normalization (RevIN): A standard preprocessing step to handle distribution shifts and non-stationary data common in time series.
Datasets
The model was evaluated on 8 widely-used real-world multivariate time series benchmarks:
- ETT (ETTh1, ETTh2, ETTm1, ETTm2): Electricity Transformer Temperature data at different granularities.
- Electricity: Hourly consumption from 321 clients.
- Exchange: Daily currency exchange rates.
- Traffic: Road occupancy rates from 862 sensors.
- Weather: Meteorological indicators like temperature and pressure.
Key Insights and Ideas
- Attention is the Bottleneck: The authors show that a "Random Transformer" (with fixed, random attention weights) actually generalizes better than a fully trained one, proving that the standard way we train attention is what causes the failure.
- Escaping Entropy Collapse: Standard training leads to attention matrices that look like identity matrices almost immediately. SAM helps maintain "expressive" attention, allowing the model to continue learning feature correlations.
- Flatness is Key for Generalization: By using SAM, the authors achieved a loss landscape with a maximum Hessian eigenvalue ($\lambda_{max}$) orders of magnitude smaller than standard training, directly translating to better test performance.
Key Results
SAMformer sets a new state-of-the-art for multivariate long-term forecasting:
- Superior Accuracy: It outperforms the previous state-of-the-art (SOTA), TSMixer, by 14.33% on average across all datasets and horizons. It also beats the best previous transformer-based model, FEDformer, by 12.36%.
- Extreme Efficiency: Despite its performance, SAMformer has ~4 times fewer parameters than TSMixer and is orders of magnitude smaller than typical transformer models.
- Foundation Model Performance: It performs on par with (and sometimes better than) massive foundation models like MOIRAI (which has up to 314M parameters), despite being a fraction of the size.
- Robustness: As shown in Figure 1, SAMformer (Transformer + SAM) is the only variant that successfully reaches the optimal "Oracle" solution on synthetic data, while others overfit or fail to converge.
Limitations and Future Work
- Shallow Focus: The current work focuses on a single-layer architecture. While highly effective, exploring whether deeper SAM-optimized transformers can unlock even more potential is an open question.
- Full-shot vs. Zero-shot: SAMformer excels in the "full-shot" setting (trained on the target dataset). It does not aim to replace the zero-shot capabilities of massive foundation models trained on billions of samples, though it serves as a much more efficient alternative for specific tasks.
- Hyperparameter Sensitivity: While SAMformer requires less tuning than some competitors, the neighborhood size parameter ($\rho$) in SAM still needs careful selection to balance flatness and accuracy.
Summary updated