Abstract
The self-attention mechanism in Transformer architecture, invariant to sequence order, necessitates positional embeddings to encode temporal order in time series prediction. We argue that this reliance on positional embeddings restricts the Transformer's ability to effectively represent temporal sequences, particularly when employing longer lookback windows. To address this, we introduce an innovative approach that combines Pyramid RNN embeddings (PRE) for univariate time series with the Transformer's capability to model multivariate dependencies. PRE, utilizing pyramidal one-dimensional convolutional layers, constructs multiscale convolutional features that preserve temporal order. Additionally, RNNs, layered atop these features, learn multiscale time series representations sensitive to sequence order. This integration into Transformer models with attention mechanisms results in significant performance enhancements. We present the PRformer, a model integrating PRE with a standard Transformer encoder, demonstrating state-of-the-art performance on various real-world datasets. This performance highlights the effectiveness of our approach in leveraging longer lookback windows and underscores the critical role of robust temporal representations in maximizing Transformer's potential for prediction tasks.
Introduction
While Transformers have revolutionized Natural Language Processing and Computer Vision, their application to time series forecasting has faced significant challenges. Recent studies indicate that simple linear models often outperform complex Transformers in this domain. Two primary issues hinder standard Transformer performance:
- Permutation Invariance: The self-attention mechanism does not inherently understand sequence order. Standard Transformers rely on positional embeddings to inject time information, but these often fail to capture the nuanced sequential patterns found in long-term time series data.
- Quadratic Complexity: The $O(L^2)$ computational cost of standard self-attention makes utilizing long historical windows prohibitively expensive, even though such windows are often necessary for accurate forecasting.
The PRformer Architecture
The core innovation of PRformer is the Pyramidal RNN Embedding (PRE) module. Instead of feeding raw data points into a Transformer, PRformer first processes univariate series through a multi-stage pipeline designed to extract multiscale features while preserving temporal order.
The PRE module consists of three key components:
- Bottom-Up Pathway: 1D convolutional layers with varying strides create a "feature pyramid," extracting patterns at different scales (e.g., hourly, daily, weekly).
- Top-Down Pathway & Lateral Connections: This structure fuses high-level macroscopic trends with low-level microscopic details, similar to Feature Pyramid Networks in image recognition.
- Multi-Scale RNN (GRU): Compressed features from the pyramid are processed by Gated Recurrent Units. Because the convolutions have already reduced the sequence length, the RNN can process the data efficiently without the typical "vanishing gradient" issues associated with very long sequences.
Once the PRE has captured the temporal logic of each individual variable, a standard Transformer encoder models the multivariate dependencies, capturing how different variables (e.g., humidity and wind speed) interact to affect the forecast.
Experimental Results
PRformer was evaluated on eight widely recognized real-world benchmarks, including ETT (Electricity Transformer Temperature), Weather, Electricity usage, Traffic occupancy, and Solar-Energy production.
Performance and Scalability
PRformer achieved state-of-the-art performance, securing the best results in 25 out of 32 MSE metrics across the tested datasets. Notably, adding the PRE module to existing Transformer variants like Informer or Reformer yielded performance improvements of 30% to 50%. Furthermore, unlike vanilla Transformers which often see performance plateau or degrade as the lookback window increases, PRformer’s error consistently decreases as it is given more historical data.
Computational Efficiency
Beyond accuracy, PRformer demonstrates superior efficiency. By downsampling through the pyramid, the model achieves a complexity of $O(L/W + D^2)$, effectively making the model's complexity linear relative to the input length $L$.
As shown in the figure above, PRformer is significantly faster than PatchTST, requiring nearly half the training time and as little as 1/3 of the memory. This efficiency allows for larger batch sizes and longer lookback windows on the same hardware.
Conclusion
PRformer addresses the fundamental limitations of Transformers in time series forecasting by integrating a pyramidal recurrent embedding. By treating RNNs as feature extractors that provide rich temporal context, the model overcomes permutation invariance and achieves linear scaling. While the current implementation requires manual configuration of pyramidal windows based on data frequency, future work will focus on automating this selection through adaptive mechanisms and exploring integration with more advanced attention mechanisms.
Summary updated