Autoformer: Decomposition Transformer for Long-Term Time-Series Forecasting

Machine Learning
Introduced by
Haixu Wu et al. (Tsinghua)
Year
2021
Type
Decomposition-based deep forecasting model
Family
Time-series forecasting

What does it do?

Autoformer is a deep learning architecture for long-term time-series forecasting, introduced by Wu et al. from Tsinghua University at NeurIPS 2021.

It replaces the standard self-attention mechanism with an Auto-Correlation mechanism that exploits periodic dependencies in the frequency domain, and embeds a progressive series decomposition block throughout the encoder and decoder to separately model trend and seasonal components.

The intuition behind the method

Instead of comparing every pair of time steps with dot-product attention, Autoformer finds recurring patterns by computing the auto-correlation of queries and keys in the frequency domain via Fast Fourier Transform. High-correlation lags indicate periodicity; the model aggregates value representations at those lags. Simultaneously, a moving-average decomposition block continuously separates slow-moving trend from oscillating seasonal signals, letting each component be refined independently through the network.

History

Autoformer was proposed by Haixu Wu, Jiehui Xu, Jianmin Wang, and Mingsheng Long at Tsinghua University and presented at NeurIPS 2021. Its two main contributions are the Auto-Correlation mechanism and the progressive decomposition architecture. The model has since been widely cited in Transformer-based forecasting research.

When to use it

Autoformer is a reasonable choice when the forecast horizon is long and the series shows recurring structure, such as daily or seasonal cycles in weather, electricity demand, or traffic flow. It assumes the series can be usefully split into a slowly varying trend and a seasonal remainder, and that the periodic structure persists across the forecast window. Avoid it for short horizons, short histories, or series with irregular or non-periodic dynamics, where lag-based aggregation and decomposition add little over simpler models. For alternatives with different inductive biases, Informer suits extreme-length inputs, FEDformer suits frequency-domain mixing, and TimesNet suits 2-D temporal pattern modeling.

Limitations and considerations

  • Moving-average decomposition with a fixed or heuristic kernel may not cleanly separate trend and seasonality in all series
  • Auto-Correlation assumes periodic recurrence; series with irregular or non-periodic dynamics may not benefit from lag-based aggregation
  • The model is more computationally demanding than linear forecasting baselines, so such baselines should be included in any comparison
  • Long-horizon accuracy can degrade on real-world datasets where the periodicity assumption is only partially valid

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Progressive series decomposition enables the model to separately refine trend and seasonal components at every layer
  • Auto-Correlation mechanism reduces complexity from O(L²) to O(L log L) while capturing periodic dependencies
  • Aggregation over the top-K lags ties the model's weighting to specific candidate periods. These selected lags can be examined as candidate periods, in contrast to attention weights over every individual time step. This does not by itself constitute a validated explanation of the forecast.
  • The decoder attends to encoder outputs through cross-series Auto-Correlation, so periodic patterns in the historical window can inform the future window directly

Applications

  • Long-horizon electricity consumption forecasting
  • Meteorological and climate variable prediction (temperature, wind speed, humidity)
  • Traffic flow and occupancy rate forecasting
  • Exchange rate and financial time-series trend modeling
  • Multivariate sensor data forecasting in industrial IoT systems

How it works

How it works

1

A moving-average filter, whose kernel size is a configurable hyperparameter, extracts the trend component from the input sequence. Subtracting the trend yields the seasonal residual. This decomposition block is applied progressively at every sublayer of both encoder and decoder, so trend and seasonal information stay separated as representations deepen.

Formula
\mathbf{X}_{trend} = \text{AvgPool}(\text{Padding}(\mathbf{X})), \quad \mathbf{X}_{seasonal} = \mathbf{X} - \mathbf{X}_{trend}
2

Queries and keys are transformed into the frequency domain with FFT. Their element-wise product (equivalent to circular cross-correlation) is inverted back to the time domain to obtain lag-wise correlation scores. The top-K lags are selected, and value vectors are aggregated by rolling and weighting them at those lags, achieving O(L log L) complexity instead of O(L²).

Formula
\mathcal{R}_{QK}(\tau) = \mathcal{F}^{-1}\!\left(\mathcal{F}(\mathbf{Q}) \cdot \overline{\mathcal{F}(\mathbf{K})}\right), \quad \hat{\mathbf{V}} = \sum_{k=1}^{K} \text{Roll}(\mathbf{V},\, \hat{\tau}_k) \cdot \text{Softmax}(\mathcal{R}_{QK}(\hat{\tau}_k))
3

The encoder processes the historical window by alternating Auto-Correlation sublayers with series decomposition sublayers, accumulating extracted trend tensors. The decoder begins from a concatenation of a decomposed historical tail and a learned zero-initialized future placeholder, and refines both seasonal and trend streams using cross-series Auto-Correlation with encoder outputs.

Formula
\mathbf{S}^{(l)}_{en}, \mathbf{T}^{(l)}_{en} = \text{SeriesDecomp}\bigl(\text{AutoCorr}(\mathbf{S}^{(l-1)}_{en}) + \mathbf{S}^{(l-1)}_{en}\bigr)
4

The final decoder seasonal output is projected linearly to the target dimension, and the accumulated decoder trend stream is added. This additive combination of the two separately modeled streams produces the multi-step ahead forecast, so the output reflects the decomposition structure learned throughout the network.

Formula
\hat{\mathbf{Y}} = \mathbf{W}_{\text{seasonal}} \cdot \mathbf{S}^{(M)}_{de} + \mathbf{T}^{(M)}_{de}

Common pitfalls

  • Using a poorly tuned moving-average window length can leak seasonal signal into the trend stream, corrupting both branches
  • Applying Autoformer to short time series or very short forecast horizons negates the architectural advantages designed for long-range dependencies
  • Feeding series whose level drifts across windows, without normalizing each input window, shifts the input distribution between training and inference; the moving-average trend then absorbs part of that level shift into the trend stream
  • Comparing Autoformer results without controlling for look-back window length leads to misleading benchmark comparisons

Frequently asked questions

How does Auto-Correlation differ from standard self-attention?

Standard self-attention computes pairwise similarity between every time step, scaling as O(L²). Auto-Correlation instead computes the cross-correlation between query and key sequences in the frequency domain using FFT, identifying which periodic lags are most informative and aggregating values at those lags. This reduces complexity to O(L log L) and explicitly exploits periodicity rather than arbitrary pairwise relationships.

Why is series decomposition embedded throughout the network rather than applied once at the input?

Applying decomposition only at the input produces a one-shot separation that cannot be corrected as the representation evolves. Embedding decomposition at every sublayer allows the network to progressively refine the separation: as each layer learns richer representations, residual trend signals that were missed earlier can be extracted, leading to cleaner seasonal and trend streams at the output.

Is Autoformer still competitive with more recent models?

Autoformer was a strong baseline at its release, but its performance relative to newer and simpler forecasters depends on the benchmark and evaluation protocol. It is still widely cited as a decomposition-based forecaster. It should therefore be evaluated alongside recent lightweight alternatives, including linear baselines, before deployment.

Related methods

Sources

  1. Wu, H., Xu, J., Wang, J., & Long, M. (2021). Autoformer: Decomposition transformers with auto-correlation for long-term series forecasting. NeurIPS, 34.

    Open publication reference