# Autoformer: Decomposition Transformers with Auto-Correlation for Long-Term Series Forecasting

Autoformer adds decomposition inside the network for long-term forecasting

Haixu Wu, Jiehui Xu, Jianmin Wang, Mingsheng Long · arXiv · 2021-6-24

- **Problem** Sparse self-attention keeps long-series forecasting affordable, but it aggregates single points and so throws away information.
- **Method** Autoformer puts series decomposition inside each layer instead of once on the input, and aggregates whole sub-series by matching periodic delays.
- **Results** Autoformer reduces MSE by 38% on average relative to the previous state of the art in long-term forecasting.

## Why long-horizon forecasting stalls in Transformers

Long-horizon forecasting is hard for two reasons that compound each other. The dependencies that matter can be hidden inside entangled temporal patterns, so they are hard to find directly in a long series. Canonical self-attention also scales with the square of the sequence length, which makes long inputs expensive.

The usual fix is a sparse version of self-attention that keeps only some pairs of points. That keeps the cost down, but these models still aggregate single points, so the sparse connections throw away information. LogTrans, Reformer and Informer each pick the points differently, yet they keep the same point-wise dependency and aggregation.

Decomposition is a standard way to untangle a series into more predictable parts. In forecasting, however, it is usually applied only to the past input, because the future is unknown. That leaves the interactions between the components of the future unmodeled, and the authors set out to fix exactly that gap.

## Decomposition as an inner block of the network

Autoformer keeps decomposition inside the network, so every layer splits its hidden series again while the forecast is being built. This lets the model separate the long-term trend from the predicted hidden variables step by step, instead of once at the input.

The inner block is a moving average with padding, which keeps the length of the series unchanged. For an input \\\\(X\\\\in\\\\mathbb{R}^{L\\\\times d}\\\\), the trend-cyclical part is \\\\(X\_t = \\\\mathrm{AvgPool}(\\\\mathrm{Padding}(X))\\\\), and the seasonal part is what remains, \\\\(X\_s = X - X\_t\\\\). The moving average smooths out periodic fluctuations, so the trend is what survives the smoothing and the seasonal part keeps the fluctuations.

The decoder starts from two parts built from the encoder input. The seasonal initialization concatenates the seasonal half of the last \\\\(I/2\\\\) input steps with zeros for the \\\\(O\\\\) future steps, and the trend initialization concatenates the trend half with the mean of the input. Because the future has no observations, the placeholders give the decoder a starting point to refine.

## How encoder and decoder layers pass information

The encoder focuses on the seasonal part, and each layer runs Auto-Correlation followed by a decomposition, then a feed-forward step followed by another decomposition. The trend parts removed in the encoder are discarded, and the seasonal output is passed on as the cross information for the decoder.

Each decoder layer has an inner Auto-Correlation, an encoder-decoder Auto-Correlation, and a feed-forward step, with a decomposition after each. Each decomposition produces a trend part that is projected and added to a running trend, so the trend prediction is refined layer by layer. The final prediction sums the refined trend and the deep-transformed seasonal part, after projecting the seasonal part to the target dimension.

## Auto-Correlation replaces self-attention

The mechanism rests on the idea that the same phase position across periods gives similar sub-processes. Autocorrelation \\\\(R\_{XX}(\\\\tau)\\\\) measures how similar a series is to its own copy delayed by \\\\(\\\\tau\\\\) steps, and the authors use it as an unnormalized confidence for each candidate period length. Its definition is \\\\(R\_{XX}(\\\\tau) = \\\\lim\_{L\\\\to\\\\infty}\\\\frac{1}{L}\\\\sum\_{t=1}^{L} X\_t X\_{t-\\\\tau}\\\\).

The model takes the \\\\(k\\\\) delays with the largest autocorrelation, where \\\\(k=\\\\lfloor c\\\\times\\\\log L\\\\rfloor\\\\) and \\\\(c\\\\) is a hyper-parameter. A softmax over those autocorrelation values gives the weights, and each selected delay rolls the values \\\\(V\\\\) by \\\\(\\\\tau\_i\\\\) before weighting. Rolling moves the elements shifted past the first position to the last position, so sub-series at the same phase line up.

For the encoder-decoder version, the keys and values come from the encoder output and are resized to length \\\\(O\\\\), while the queries come from the previous decoder block. The autocorrelation for all lags can be computed at once with the fast Fourier transform, through the Wiener–Khinchin relation. Because only about \\\\(\\\\log L\\\\) series are aggregated, the authors state the cost as \\\\(O(L\\\\log L)\\\\).

Self-attention relates scattered points and aggregates them by dot product, while Auto-Correlation connects whole sub-series across periods. The authors argue that this series-level aggregation keeps the information the sparse point-wise variants discard, while staying cheap.

## Multivariate forecasts against recurrent, convolutional and Transformer baselines

The authors test six benchmarks, from ETT and Electricity to Exchange, Traffic, Weather and ILI, at prediction lengths 96, 192, 336 and 720. The input length is 96 for all datasets except ILI, which uses 36, and the baselines include Informer, Reformer, LogTrans, LSTNet, LSTM and TCN.

On the ETT setting with input 96 and prediction 336, Autoformer reached an MSE of 0.339, compared to 1.334 for LogTrans. Note that the table row labelled ETT is ETTm2, and the paper points to its appendix for the other ETT datasets.

On Electricity at the same input and prediction lengths, Autoformer scored 0.231, compared to 0.280 for LogTrans, an 18% reduction. On Exchange, Autoformer scored 0.509, compared to 1.357 for Reformer, a 61% reduction. The Exchange gain matters because the authors describe that series as having no obvious periodicity, so the period-based design is not the only source of the gain they claim.

Averaged over the settings the authors list, Autoformer reduces MSE by 38% relative to the previous state of the art. The authors also say the MSE of Autoformer rises only slowly with the prediction length, which they read as better long-term robustness.

## Univariate results and the ARIMA caveat

The univariate comparison uses input length 96 and includes N-BEATS, Informer, LogTrans, Reformer, DeepAR, Prophet and ARIMA. On Exchange at prediction length 96, ARIMA scored 0.112, while Autoformer scored 0.241. The authors explain this by ARIMA's fit to non-stationary economic data, and they note that ARIMA fails once the horizon grows.

Table 2 lists 0.154 for Autoformer at that setting, so the text and the table disagree on this value.

On univariate Exchange at the same horizon, the text reports a 17% reduction from 0.611 to 0.508.

## Does the decomposition block help other Transformers?

The authors compare three versions of each model on ETT with input 96: the original, a Sep version that forecasts pre-decomposed components with two models, and an Ours version that uses the progressive architecture. The Ours version lowers MSE for Transformer, Informer, LogTrans and Reformer, and the gain grows with the prediction length.

For Transformer at prediction length 720, MSE goes from 2.672 to 0.537 with the Ours version.

Pre-decomposition helps at short horizons but hurts at long ones. Sep lowers Transformer MSE at prediction length 96 from 0.604 to 0.311, but at prediction length 720 it raises it from 2.672 to 3.200. The authors attribute this to pre-decomposing ignoring how components interact over the long future, and the Sep model also has more parameters.

## Auto-Correlation against other attention variants

The authors swap Auto-Correlation in Autoformer for full, LogSparse, LSH and ProbSparse attention, and compare MSE and MAE at input lengths 96, 192 and 336 with prediction lengths 336, 720 and 1440. At input 96 and prediction 336, Auto-Correlation scored 0.339, compared to 0.375 for full attention and 0.481 for ProbSparse. In every cell that has a value, Auto-Correlation has the lowest MSE among the four variants.

Several variants run out of memory at the longest settings, which the authors take as evidence that Auto-Correlation scales better. At input 336 and prediction 1440, Auto-Correlation reached 0.574, while ProbSparse reached 1.133.

## Cost and the learned periods

The efficiency comparison measures memory with input length 96, and it times running steps during training for Auto-Correlation and the self-attention variants. The authors report that Autoformer shows \\\\(O(L\\\\log L)\\\\) complexity in both memory and running time. These efficiency numbers come from separate runs and are not a claim about the accuracy of the same trained model.

The learned lags are the top 10 lags from the decoder on the test set, for the input-96-predict-336 task. For Exchange the lags show monthly, quarterly and yearly periods, and for Traffic they show 24-hour and 168-hour intervals. The authors read these as matches to real periods, which makes the predictions easier to interpret.

## Limitations

The hyper-parameter c is set in the range 1 to 3 to trade off performance and efficiency. The main multivariate table uses the ETTm2 variant for its ETT row, and the other ETT datasets appear only in the appendix. The decomposition ablation covers only ETT and reports only MSE, so it does not test the other datasets.

The attention ablation fixes input lengths 96, 192 and 336, and it covers only ETT. The efficiency memory check uses input length 96. The ETT univariate figure appears as 0.145 in the text and 0.154 in Table 2, and the paper does not resolve which is correct.

## Paper info

- **Authors**: Haixu Wu, Jiehui Xu, Jianmin Wang, Mingsheng Long
- **Venue**: arXiv · Preprint
- **First published**: 2021-6-24
- **Added**: 2026-11-12
- **Updated**: 2022-1-7
- **Version**: v5
- **arXiv**: 2106.13008
- **Category**: cs.LG · cs.AI
- **Original paper terms**: [CC BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/2106.13008v5) · [PDF ↗](https://arxiv.org/pdf/2106.13008v5)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Haixu Wu, Jiehui Xu, Jianmin Wang, Mingsheng Long (2021). Autoformer: Decomposition Transformers with Auto-Correlation for Long-Term Series Forecasting. arXiv:2106.13008v5. https://arxiv.org/abs/2106.13008v5

**BibTeX**

```
@misc{wu2021autoformer,
  title = {{Autoformer: Decomposition Transformers with Auto-Correlation for Long-Term Series Forecasting}},
  author = {Haixu Wu and Jiehui Xu and Jianmin Wang and Mingsheng Long},
  year = {2021},
  eprint = {2106.13008},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2106.13008v5}
}
```

## Other paper commentary

- [DeepSurv: Personalized Treatment Recommender System Using A Cox Proportional Hazards Deep Neural Network](https://refivu.com/en/papers/e56bf111-97b6-4d99-b702-a3e324f609b2-deepsurv-personalized-treatment-recommender-system-using-a.md)
- [BinaryConnect: Training Deep Neural Networks with binary weights during propagations](https://refivu.com/en/papers/50c59bf6-7b51-443a-b99a-d2bbc087f3e9-binaryconnect-training-deep-neural-networks-with-binary.md)
- [Deep Networks with Stochastic Depth](https://refivu.com/en/papers/a740a8af-8c09-4c4a-92ca-ab98a84c56cf-deep-networks-with-stochastic-depth.md)
- [Deep Transfer Learning with Joint Adaptation Networks](https://refivu.com/en/papers/a47a8c83-de4b-469b-a9c2-9df2e72bbd27-deep-transfer-learning-with-joint-adaptation-networks.md)
- [A Structured Self-attentive Sentence Embedding](https://refivu.com/en/papers/a8cbdabb-c63d-415b-8edf-e85be94428b8-a-structured-self-attentive-sentence-embedding.md)
- [Meta-Learning in Neural Networks: A Survey](https://refivu.com/en/papers/c729f50c-a819-4d71-934d-d46e25ac8859-meta-learning-in-neural-networks-a-survey.md)
- [Targeted Backdoor Attacks on Deep Learning Systems Using Data Poisoning](https://refivu.com/en/papers/4dc3fc3a-5207-430d-b5ed-3cc95d077c11-targeted-backdoor-attacks-on-deep-learning-systems-using.md)
- [M3-Embedding: Multi-Linguality, Multi-Functionality, Multi-Granularity Text Embeddings Through Self-Knowledge Distillation](https://refivu.com/en/papers/c3b40084-e91f-4769-ab5c-b3256a5b92f7-m3-embedding-multi-linguality-multi-functionality-multi.md)
- [Graph Convolutional Networks for Text Classification](https://refivu.com/en/papers/3f1e8027-a608-4e71-87f0-2bdbf0fd5a7f-graph-convolutional-networks-for-text-classification.md)
- [Open3D: A Modern Library for 3D Data Processing](https://refivu.com/en/papers/d0e7cf62-d439-416d-a785-974f817c8a48-open3d-a-modern-library-for-3d-data-processing.md)
- [PCT: Point cloud transformer](https://refivu.com/en/papers/54b01448-d153-4635-92bf-22ab3866d1ae-pct-point-cloud-transformer.md)
- [Learning Deep CNN Denoiser Prior for Image Restoration](https://refivu.com/en/papers/e6af5c0e-57ae-4b96-acf1-3a40058beb53-learning-deep-cnn-denoiser-prior-for-image-restoration.md)

## Terms in this paper

- [Transformer](https://refivu.com/en/terms/48e8be2570bc-transformer)
- [self-attention](https://refivu.com/en/terms/426589b81077-self-attention)
- [MAE](https://refivu.com/en/terms/15fbae569b33-mae)
- [MSE](https://refivu.com/en/terms/aaced1b84616-mse)
- [Informer](https://refivu.com/en/terms/d78e669bc4ea-informer)
- [Reformer](https://refivu.com/en/terms/09e7750949bd-reformer)
- [Autoformer](https://refivu.com/en/terms/609d9af96ac4-autoformer)
- [Electricity](https://refivu.com/en/terms/b06d89f2b10d-electricity)
- [LogTrans](https://refivu.com/en/terms/0446cb24885e-logtrans)
- [LSTNet](https://refivu.com/en/terms/84eba7c766ac-lstnet)
- [Time Series Forecasting](https://refivu.com/en/terms/c2a8e3800569-time-series-forecasting)
- [ARIMA](https://refivu.com/en/terms/4c8179f83b57-arima)
- [DeepAR](https://refivu.com/en/terms/4ddada502d0f-deepar)
- [long-term forecasting](https://refivu.com/en/terms/6860520adbc0-long-term-forecasting)
- [Prophet](https://refivu.com/en/terms/f5193ba1cff1-prophet)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/d52df827-0d8c-42c3-97e1-3063d2cc1256-autoformer-decomposition-transformers-with-auto-correlation)
