Are Transformers Effective for Time Series Forecasting?
Are Transformers Effective for Time Series Forecasting?

For the past year, I’ve been asking myself the same question: “Are Transformers Effective for Time Series Forecasting?” Recently, I came across this paper [5] that discusses this topic in more detail.
It’s true that a lot of progress has been made in this field with very well-designed models attempting to overcome the limitations of Vanilla Transformers in forecasting tasks.
One of these limitations is the quadratic time/complexity of the original self-attention. To deal with it, most models use specialized self-attention blocks.
For example, Informer [1] uses ProbSparse Attention to decrease complexity to O(LlogL), while FEDFormer [2] uses Frequency Enhanced Blocks and Frequency Enhanced Self-Attentions to perform representation learning in the frequency domain, ultimately reducing complexity to linear. My personal favorite is PyraFormer [3], which uses Hierarchical Self-Attention to describe temporal dependencies through multiresolutions (aka Temporal Hierarchies, see my other Medium Posts), reducing complexity to O(L).

Other limitations, including bias towards overly smooth solutions and rotationally invariant learning, are inherited from the limitations of deep learning models for tabular data in general. These are discussed in more detail in [4].
Still, the most important limitation is that self-attention is permutation-invariant (anti-order) while time series observations have strong temporal relationships [5]. For semantic applications like NLP, this is not a big issue as rearranging some words doesn’t greatly change the overall semantic meaning. However, for time series, even with multiple positional encoding techniques to preserve temporal information, it’s not enough. Positional encoding only encodes ordering information to some extent.
To address this limitation, several models use specialized architectures in order to preserve some of the temporal information. LogTrans [6] uses convolution self-attention to preserve local context, Non-Stationary-Transformer [7] uses De-Stationary-Attention to discover temporal dependencies through exploiting stationarity, AutoFormer [8] applies seasonal-trend decomposition, etc.

The questions that arise are the following:
- Is it worth adding all these complex blocks to deal with the limitations of the Vanilla Transformers?
- Are these models robust enough to work in a production environment with different real-world settings?
- Are the reported accuracy improvements in long-term forecasting a product of the adjusted self-attention or from other components (eg Direct Multistep Forecasting Strategy?)[5]
Another issue is model evaluation. Are these models properly benchmarked before claiming SOTA performance on some datasets? For example, according to [9], a non-trainable model with 0 parameters outperforms the AutoFormer transformer on multiple tasks. Then, in [5], researchers use very simple sets of linear models that implement Direct Multistep Forecasting to outperform most established transformers.

It’s clear that something is missing from the puzzle. Something that will unlock the full potential of Transformers for forecasting.
On the other hand, I’m certain that with careful tuning, these models can work and show improvements on the given forecasting task. We know for a fact that experts in the field of Operational Forecasting at Scale like Amazon use them effectively in production [10].
Additionally, during the International Symposium on Forecasting (ISF) on 2022, another group of experts, the Zalando forecasting team presented their Transformer model used in production with excellent results. Unfortunately, there’s no publication yet, but I’m pretty sure this will change soon :).
So are these models worth using for forecasting purposes?
For sure they are not the go-to model as they are for NLP tasks. There are multiple, established and battle-tested models that have been widely used in a production environment. These models are currently preferred over Transformers, and for a good reason. We still do not have enough evidence to suggest that Transformers offer significant benefits considering their implementation costs.
However, under the right circumstances, and especially given the appropriate expertise to effectively implement and maintain them, they can be effective.
To get started on the field [12] gives a nice survey of Transformers for time series forecasting and [13] is a great walkthrough on how to implement Transformers for forecasting using Hugging Face.
I’m looking forward to the future of Transformers and Time Series Forecasting.
References:
[1] Zhou, Haoyi, et al. “Informer: Beyond efficient transformer for long sequence time-series forecasting.” Proceedings of the AAAI conference on artificial intelligence. Vol. 35. №12. 2021.
[2] Zhou, Tian, et al. “Fedformer: Frequency enhanced decomposed transformer for long-term series forecasting.” International Conference on Machine Learning. PMLR, 2022.
[3] Liu, Shizhan, et al. “Pyraformer: Low-complexity pyramidal attention for long-range time series modeling and forecasting.” International conference on learning representations. 2021.
[4] Grinsztajn, Léo, Edouard Oyallon, and Gaël Varoquaux. “Why do tree-based models still outperform deep learning on tabular data?.” arXiv preprint arXiv:2207.08815 (2022).
[5] Zeng, Ailing, et al. “Are transformers effective for time series forecasting?.” arXiv preprint arXiv:2205.13504 (2022).
[6] Li, Shiyang, et al. “Enhancing the locality and breaking the memory bottleneck of transformer on time series forecasting.” Advances in neural information processing systems 32 (2019).
[7] Liu, Yong, et al. “Non-stationary transformers: Rethinking the stationarity in time series forecasting.” arXiv preprint arXiv:2205.14415 (2022).
[8] Wu, Haixu, et al. “Autoformer: Decomposition transformers with auto-correlation for long-term series forecasting.” Advances in Neural Information Processing Systems 34 (2021): 22419–22430.
[9] Sun, Fan-Keng, and Duane S. Boning. “Fredo: frequency domain-based long-term time series forecasting.” arXiv preprint arXiv:2205.12301 (2022).
[10] Chen, Kevin C., et al. “MQTransformer: Multi-horizon forecasts with context dependent attention and optimal bregman volatility.” (2022).
[11] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez,
Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information
processing systems, pp. 5998–6008, 2017.
[12] Wen, Qingsong, et al. “Transformers in time series: A survey.” arXiv preprint arXiv:2202.07125 (2022).
[13] https://huggingface.co/blog/time-series-transformers
[14] Amatriain, Xavier. “Transformer models: an introduction and catalog.” arXiv preprint arXiv:2302.07730 (2023).