Search

Search papers and lessons

Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting

Haoyi Zhou, Shanghang Zhang, Jieqi Peng et al. · 2020

Informer adapts the Transformer to forecast long stretches of a time series, using sparse attention, halving encoder layers and one-pass decoding to cut time, memory and inference cost.

On this page

  • Colour = topic mix
  • Probability
  • Architectures
  • Calculus
  • Discrete math
  • Linear algebra
  • Neural network basics
  • ReadReady to readNot yet

TL;DR

Informer is a Transformer built for long-horizon forecasting: given many past readings of a time series, it predicts a long stretch of future readings in one shot. It keeps the Transformer's ability to link any two time steps directly, and it removes the three costs that make the vanilla model impractical at that length: quadratic attention, memory that grows with every stacked layer, and slow step-by-step output. On several real datasets its error rises slowly as the forecast gets longer, while the baselines' error climbs much faster.

Builds on: Transformer, Time Series Forecasting, Encoder-Decoder Architecture · Leads to: Autoformer: Decomposition Transformers with Auto-Correlation, A Time Series is Worth 64 Words: Long-term Forecasting with Transformers, Are Transformers Effective for Time Series Forecasting?

Why it mattered

Long-horizon forecasting feeds planning decisions. The paper's motivating case is a power utility that must know the temperature of an electrical transformer station, and the load on the grid, days or weeks ahead. Informer was one of the earliest Transformer models designed for that task rather than for language. It released a new dataset of transformer-station temperatures (the ETT data) and its code, so later papers could compare against it. Autoformer, which is an Informer successor, and PatchTST both report results on the same kind of benchmark. DLinear later used these benchmarks to question whether attention helps at all, which is why the Informer results are still read carefully.

The problem

Before this work, most forecasters were tested on short horizons, typically 48 points or fewer. The paper's Figure 1 shows an LSTM forecasting the hourly temperature of a transformer station. As the forecast grows from 12 points (half a day) to 480 points (20 days), the error stays manageable up to about 48 points and then rises sharply, and the inference speed drops.

The Transformer is the natural tool here, because self-attention links any two time steps through a path of length one, where a recurrent network needs a path as long as the gap. But the vanilla model has three limits on long inputs and outputs. Each limit is stated in terms of the input length LL and the number of stacked layers JJ:

  1. Quadratic attention. Each layer compares every query with every key, so time and memory per layer are O(L2)\mathcal{O}(L^2).
  2. Memory across layers. Stacking JJ layers multiplies that cost, giving O(J⋅L2)\mathcal{O}(J \cdot L^2) total memory. Long inputs stop fitting on one GPU.
  3. Slow long outputs. A standard decoder predicts one value at a time and feeds each prediction back in, so predicting LyL_y values takes LyL_y sequential passes, which is as slow as an RNN.

Earlier work tackled the first limit with sparse patterns such as the Sparse Attention of Sparse Transformer and Longformer, or with hashing (Reformer) and low-rank projections (Linformer). The paper argues these efforts left limits 2 and 3 untouched, and that the goal for forecasting is improvement beyond efficiency: a bigger prediction capacity, meaning the ability to link the far future to the far past, at a cost the hardware can carry.

Earlier attempts and history

Forecasting was dominated by classical models such as ARIMA and by recurrent networks such as the LSTM, which read a series one step at a time and struggled as sequences grew longer. The Transformer, introduced in 2017, replaced recurrence with attention, and its cost is quadratic in sequence length. From 2019 to 2020, several groups proposed sparse or approximate attention to cut that cost, including the Sparse Transformer, LogSparse, Longformer, Reformer and Linformer. Informer was posted to arXiv in December 2020 and aimed those efforts at the forecasting problem, adding distilling and the one-pass decoder so that both memory and output speed were addressed. The paper's data and code were released publicly, which made it a common reference point for the Transformer-based forecasters that followed.

How it works

Informer has an encoder that reads the past, and a decoder that writes the future. The diagram shows the path of one input.

flowchart LR
  A[Past values with time stamps] --> B[Input embedding: value plus position plus calendar]
  B --> C[ProbSparse attention with distilling, repeated]
  C --> D[Encoder output]
  D --> E[Decoder: start token plus zero placeholders]
  E --> F[All future values in one pass]

Take a tiny instance: 8 past hourly readings, and a forecast of the next 4 readings. Every number is kept small so each step can be checked by hand.

  1. Embed each time step. Each of the 8 readings becomes one vector. The vector is the reading's value, plus a fixed position code that says which slot it occupies, plus learned embeddings of calendar stamps such as hour of day and day of week. Check: 8 readings give 8 vectors; the vector length is the model width.

  2. Score how informative each query is. Attention lets each time step (a query) compare itself with every other step (its keys). For each query the model measures how far its attention spread is from uniform. A query whose attention is almost uniform adds little: its output is close to the average of the values. The model keeps the top uu queries, where uu is a constant times ln⁡L\ln L, and gives the rest the average of the values. This is the ProbSparse attention (defined in the math below), and the name comes from the sparse set of queries that receive the full computation. Check: with 8 queries and the constant set to 5, u=5ln⁡8≈10.4u = 5 \ln 8 \approx 10.4, which is more than 8, so this toy keeps every query. The saving only appears at lengths where uu is much smaller than LL.

  3. Distil: halve the sequence between layers. The attention output goes through a 1-D convolution, an exponential linear unit (ELU, a smooth activation that is negative for negative inputs), and a max-pool with stride 2. The pool keeps the strongest response in each pair of time steps. Check: 8 time steps become 4.

  4. Run a second, shorter stack in parallel. The encoder also builds replicas of the stack on halved inputs and drops one distilling layer at a time, like a pyramid. The experiments pair the full-length stack with a quarter-length one, so the model sees both the full history and a more compressed version. The encoder output concatenates the stacks. Check: each stack's output has the same width, so they can be joined.

  5. Decode in one pass. The decoder input is a start token (the last known values, here 2 readings) followed by 4 placeholder zeros, one per future step. Masked attention stops each placeholder from looking at later placeholders. A linear layer turns every position into a forecast. Check: 2 + 4 = 6 decoder positions; 4 forecasts come out after a single forward pass.

  6. Train on the error. The 4 forecasts are compared with the 4 true readings using mean squared error, and the gradient flows back through the decoder, the encoder and the attention layers. Check: a forecast 1 degree too high and one 2 degrees too high contribute 1 and 4 to the sum before averaging.

The uniform input in step 1 matters more than it looks. The paper argues that long-range forecasting needs global context such as the week, the month or a holiday, and that plain Transformer position codes carry only the local order.

The math

Definition: Query sparsity measurement

For a query qi\mathbf{q}_i and keys K=(k1,…,kLK)\mathbf{K} = (\mathbf{k}_1, \ldots, \mathbf{k}_{L_K}), with scaled scores sij=qikj⊤/ds_{ij} = \mathbf{q}_i \mathbf{k}_j^\top / \sqrt{d}, the measurement is

M(qi,K)=ln⁡∑j=1LKesij−1LK∑j=1LKsij.M(\mathbf{q}_i, \mathbf{K}) = \ln \sum_{j=1}^{L_K} e^{s_{ij}} - \frac{1}{L_K} \sum_{j=1}^{L_K} s_{ij}.

It is the log-sum-exp of the scores minus their mean. A query whose scores are all equal has the smallest value; a query with one dominant score has a large one.

Step 2 in symbols: ProbSparse attention

The paper writes the gap between the attention distribution p(kj∣qi)p(\mathbf{k}_j \mid \mathbf{q}_i) and the uniform distribution 1/LK1/L_K as a KL divergence. Dropping the constant that does not depend on the query gives the measurement above.

Computing MM exactly needs every dot product, which is the quadratic cost we wanted to avoid. The paper replaces the log-sum-exp with the max, giving

M‾(qi,K)=max⁡jsij−1LK∑j=1LKsij,\overline{M}(\mathbf{q}_i, \mathbf{K}) = \max_j s_{ij} - \frac{1}{L_K} \sum_{j=1}^{L_K} s_{ij},

and bounds the error with a lemma:

ln⁡LK≤M(qi,K)≤max⁡jsij−1LK∑j=1LKsij+ln⁡LK.\begin{aligned} \ln L_K &\le M(\mathbf{q}_i, \mathbf{K}) \\ &\le \max_j s_{ij} - \frac{1}{L_K} \sum_{j=1}^{L_K} s_{ij} + \ln L_K. \end{aligned}

The max-mean value is therefore a usable proxy for the true measure. In practice the paper samples only U=LKln⁡LQU = L_K \ln L_Q random dot products to estimate it.

Then ProbSparse attention keeps the top uu queries under this measure and fills the rest with the mean of the values:

A(Q,K,V)=Softmax⁡(Q‾K⊤d)V,u=c⋅ln⁡LQ,\mathcal{A}(\mathbf{Q}, \mathbf{K}, \mathbf{V}) = \operatorname{Softmax}\left(\frac{\overline{\mathbf{Q}} \mathbf{K}^\top}{\sqrt{d}}\right) \mathbf{V}, \qquad u = c \cdot \ln L_Q,

where Q‾\overline{\mathbf{Q}} holds only the top uu queries and cc is the sampling factor. With LQ=LK=LL_Q = L_K = L, the time and memory of a layer are O(Lln⁡L)\mathcal{O}(L \ln L).

Step 3 in symbols: distilling

Xj+1=MaxPool⁡(ELU⁡(Conv1d⁡([Xj]AB))),\mathbf{X}_{j+1} = \operatorname{MaxPool}\left(\operatorname{ELU}\left(\operatorname{Conv1d}\left([\mathbf{X}_j]_{\mathrm{AB}}\right)\right)\right),

where [Xj]AB[\mathbf{X}_j]_{\mathrm{AB}} is the attention block at layer jj, the convolution has kernel width 3 along time, and the max-pool has stride 2. Each layer halves the time length, so the total memory over the stack is O((2−ϵ)Lln⁡L)\mathcal{O}((2-\epsilon) L \ln L) for a small ϵ>0\epsilon > 0.

Step 5 in symbols: the decoder input

Xde=Concat⁡(Xtoken,X0)∈R(Ltoken+Ly)×dmodel,\mathbf{X}_{\mathrm{de}} = \operatorname{Concat}(\mathbf{X}_{\mathrm{token}}, \mathbf{X}_{\mathbf{0}}) \in \mathbb{R}^{(L_{\mathrm{token}} + L_y) \times d_{\mathrm{model}}},

where Xtoken\mathbf{X}_{\mathrm{token}} is the known start segment and X0\mathbf{X}_{\mathbf{0}} is a block of LyL_y zeros. Future positions are masked so each one attends only to earlier positions, and one forward pass produces all LyL_y outputs.

Step 6 in symbols: the loss

MSE=1n∑i=1n(yi−y^i)2,\mathrm{MSE} = \frac{1}{n} \sum_{i=1}^{n} \left(\mathbf{y}_i - \hat{\mathbf{y}}_i\right)^2,

averaged over the forecast window. The paper also reports MAE, the same average with absolute values in place of squares.

Worked examples

Example
1. Tiny: a query with one dominant key

Four keys, so LK=4L_K = 4. Query 1 has scaled scores (2,0,0,0)(2, 0, 0, 0).

  1. Exponentiate each score: e2≈7.389e^2 \approx 7.389, and e0=1e^0 = 1 three times.
  2. Add them: 7.389+3=10.3897.389 + 3 = 10.389.
  3. Take the log: ln⁡10.389≈2.341\ln 10.389 \approx 2.341. This is the log-sum-exp term.
  4. Take the mean of the scores: (2+0+0+0)/4=0.5(2 + 0 + 0 + 0) / 4 = 0.5.
  5. Subtract: M=2.341−0.5≈1.841M = 2.341 - 0.5 \approx 1.841.
  6. Compute the max-mean proxy: max⁡js1j−0.5=2−0.5=1.5\max_j s_{1j} - 0.5 = 2 - 0.5 = 1.5.
  7. Check the lemma: ln⁡4≈1.386≤1.841≤1.5+1.386=2.886\ln 4 \approx 1.386 \le 1.841 \le 1.5 + 1.386 = 2.886. The bound holds.

Query 2 has scores (1,1,1,1)(1, 1, 1, 1).

  1. Log-sum-exp: ln⁡(4e)=ln⁡4+1≈2.386\ln(4e) = \ln 4 + 1 \approx 2.386. Mean: 11. So M=1.386=ln⁡4M = 1.386 = \ln 4.
  2. Max-mean proxy: 1−1=01 - 1 = 0.

Interpretation: query 1 has a clear favourite key, so its attention is far from uniform and it ranks above query 2 (1.841 against 1.386). Query 2 attends uniformly, so it gets the average of the values, and it is dropped from the top uu.

Example
2. Standard: distilling a two-week input

Feed 336 hourly readings (14 days) through three distilling layers, and count the entries in the full attention matrices, one matrix per layer, one head.

  1. Without distilling, each of the 3 layers holds a 336×336336 \times 336 matrix: 3362=112,896336^2 = 112{,}896 entries. Three layers total 3×112,896=338,6883 \times 112{,}896 = 338{,}688.
  2. With distilling, the length halves after each layer: 336→168→84336 \rightarrow 168 \rightarrow 84.
  3. Layer 1 holds 3362=112,896336^2 = 112{,}896 entries.
  4. Layer 2 holds 1682=28,224168^2 = 28{,}224 entries.
  5. Layer 3 holds 842=7,05684^2 = 7{,}056 entries.
  6. Total with distilling: 112,896+28,224+7,056=148,176112{,}896 + 28{,}224 + 7{,}056 = 148{,}176.
  7. Ratio: 148,176/338,688=0.4375148{,}176 / 338{,}688 = 0.4375, so the distilled stack needs less than half the memory.

Interpretation: distilling lets deeper encoders see long inputs without the memory growing with depth. The savings compound with ProbSparse, which shrinks each layer further.

Example
3. Realistic: one attention layer on a week of hourly data

Input length L=168L = 168, which is 7 days of hourly readings.

  1. Full attention needs every query against every key: 168×168=28,224168 \times 168 = 28{,}224 dot products per head.
  2. ProbSparse first samples U=LKln⁡LQ=168×ln⁡168≈168×5.124≈861U = L_K \ln L_Q = 168 \times \ln 168 \approx 168 \times 5.124 \approx 861 dot products to estimate the measure.
  3. It keeps the top u=cln⁡LQ=5×5.124≈25.6u = c \ln L_Q = 5 \times 5.124 \approx 25.6, rounded to 26, queries.
  4. Those 26 queries each take all 168 keys: 26×168=4,36826 \times 168 = 4{,}368 dot products.
  5. Total for ProbSparse: 861+4,368=5,229861 + 4{,}368 = 5{,}229.
  6. Ratio: 5,229/28,224≈0.1855{,}229 / 28{,}224 \approx 0.185, so about 19% of the work.

Interpretation: at this length the saving is large, and it grows as LL grows, because the full cost is quadratic and the ProbSparse cost is close to Lln⁡LL \ln L.

Try it: a step-by-step decoder must predict 720 hourly values (the longest ETTh1 horizon, 30 days). How many decoder forward passes does it need, and how many does Informer need? Answer: the step-by-step decoder needs 720 passes, one per predicted value, while Informer needs 1, since all 720 placeholder positions are filled in a single pass.

Results

The paper evaluates univariate forecasting on the ETT data (ETTh1, ETTh2 and ETTm1), ECL and Weather, at five horizons each. For ETTh1 at a 168-hour horizon, Informer reaches MSE 0.183 and MAE 0.346. The baselines are LSTMa at 0.236 and 0.392, DeepAR at 0.239 and 0.422, ARIMA at 0.396 and 0.504, and Prophet at 1.224 and 0.763. At the 720-hour horizon, Informer reaches MSE 0.269 and MAE 0.435, against 0.683 for LSTMa, 0.658 for DeepAR and 2.735 for Prophet.

The count row of the univariate table records how often each method wins a metric cell. Informer wins 32 cells, its canonical-attention variant wins 12, and DeepAR wins 6. In the multivariate table Informer wins 33 cells, the canonical variant 14, and LSTnet 2. At ETTh1 with a 168-hour horizon, Informer's multivariate MSE is 0.931, against 1.997 for LSTnet.

The limits are stated by the authors. On ECL, DeepAR is better at short horizons: at 168 hours its MSE is 0.315 against 0.447 for Informer, and at 336 hours it is 0.414 against 0.489. Informer is better from 720 hours on (0.540 against 0.563). The canonical-attention variant is close to Informer on these counts, which the authors read as support for the query sparsity assumption: full attention and the sparse version produce comparable attention maps. These are benchmark results on one GPU with a fixed training recipe (Adam, learning rate starting at 0.0001 and halving each epoch, batch size 32, eight epochs), not a general claim about all forecasting problems.

Limits and tradeoffs

It is tempting to think ProbSparse simply throws away attention; in fact the lazy queries still receive an output, the average of the values, and the top-uu queries get full attention. The paper's argument is that the lazy queries' full attention would be close to that average anyway, which is why dropping them costs little.

It is tempting to think halving the sequence loses too much; in fact the paper runs a shorter stack on a quarter of the input next to the full-length one, so the encoder keeps a view of the full input and a compressed view. The paper's memory test shows the cost of the alternative: the full-attention LogTrans runs out of memory in its extreme cases, while ProbSparse does not.

It is tempting to think the one-pass decoder is always more accurate; in fact it is chosen for speed and for avoiding accumulated error, and the paper's evidence is mostly on long horizons. On short horizons the gain is small, and a simpler model can be enough.

It is tempting to think a Transformer forecaster always beats classical baselines; in fact the paper's own ECL results show DeepAR ahead at horizons up to 336 hours, and DLinear later showed that a simple one-layer linear model can match or beat several Transformer forecasters on long-horizon benchmarks.

MethodTraining timeMemoryTesting steps
InformerO(Lln⁡L)\mathcal{O}(L \ln L)O(Lln⁡L)\mathcal{O}(L \ln L)1
Vanilla TransformerO(L2)\mathcal{O}(L^2)O(L2)\mathcal{O}(L^2)LL
LogTransO(Lln⁡L)\mathcal{O}(L \ln L)O(L2)\mathcal{O}(L^2)1
ReformerO(Lln⁡L)\mathcal{O}(L \ln L)O(Lln⁡L)\mathcal{O}(L \ln L)LL
LSTMO(L)\mathcal{O}(L)O(L)\mathcal{O}(L)LL

Use an Informer-style model when the horizon is long, the input history is long, and you have enough data and a GPU to train it. Avoid it for short horizons or small datasets, and always compare it against a simple linear baseline before trusting its gains.

Reading guide

Check yourself

QuestionName the three limitations of the vanilla Transformer that Informer targets.Show answer

(1) Each layer's attention costs time and memory quadratic in the sequence length, O(L2)\mathcal{O}(L^2). (2) Stacking JJ layers multiplies the memory, giving O(J⋅L2)\mathcal{O}(J \cdot L^2), which limits how long an input can be. (3) Step-by-step decoding makes the prediction of a long output as slow as an RNN, since each value needs its own pass.

QuestionA query has scaled scores (0,0,0,0,0,0,0,0)(0, 0, 0, 0, 0, 0, 0, 0) over 8 keys. What is its sparsity measurement MM, and what is the max-mean proxy?Show answer

The log-sum-exp is ln⁡(8e0)=ln⁡8≈2.079\ln(8 e^0) = \ln 8 \approx 2.079, and the mean of the scores is 0, so M=ln⁡8≈2.08M = \ln 8 \approx 2.08. The max-mean proxy is max⁡jsj−0=0−0=0\max_j s_{j} - 0 = 0 - 0 = 0. The value ln⁡8\ln 8 is the smallest MM possible for 8 keys, so this query has perfectly uniform attention and is a candidate to be dropped from the top uu.

QuestionWhy does the decoder use zero placeholders rather than feeding its own earlier predictions back in?Show answer

Because the paper's decoder produces all LyL_y outputs in one forward pass, there are no earlier predictions to feed back. This avoids the accumulated error that step-by-step decoding builds up over a long horizon, and it cuts inference to a single pass. The decoder has to learn the future from the start token and the calendar stamps alone.

QuestionYou need 48 hourly forecasts of grid load from 500 days of data, and a simple linear model already gives low error. Should Informer be your first choice?Show answer

Probably not as the first try. Informer's advantages are reported for long horizons, while the paper's own ECL results show DeepAR ahead at short ones and the authors' motivation starts from horizons above about 48 points. Start with the linear baseline, then test Informer on your data at your horizon, and compare it against the classical baselines before deciding.

Sources

Read the full paper

Haoyi Zhou, Shanghang Zhang, Jieqi Peng et al., 2020. arXiv:2012.07436