AI State of the Art
Domains/Séries temporelles/26 min
Section 235

Transformers for Time Series: the Controversy

Listen as a podcast →

A story: the star chef and the factory canteen

A three-star chef, celebrated worldwide for his fine dining, takes over a factory canteen. Everyone expects wonders. Six months later a survey lands: the workers preferred the old cook's food, simple, proven recipes. The chef's talent was never in question; his techniques, designed for a different setting, added nothing here, and his signature dish lost exactly what mattered most in a canteen: being served hot and fast.

This story played out, almost word for word, in machine learning. The Transformer architecture (the one that revolutionised language processing and gave birth to large language models) was enthusiastically applied to time-series forecasting. Brilliant teams published ever more sophisticated variants. Then one paper showed that a single linear layer beat them all on the standard benchmarks. This page tells the story of why, and why this controversy is one of the most instructive in the field.

Why the idea was tempting

The heart of a Transformer is the attention mechanism (covered in detail in the self-attention lesson): every element of a sequence can "look at" every other element directly, however far away. For text this is precious, the pronoun "she" at the end of a paragraph can link back to a name at the beginning.

For a time series the argument seemed even stronger. An electricity-consumption curve has very long dependencies: this Monday at 8am looks like every previous Monday at 8am, weeks back. Classic recurrent models, which read the curve point by point while carrying along a summary, struggle to preserve information across thousands of steps (see the lesson on deep learning for time series). Attention jumps straight from one Monday to the next. On paper, the perfect tool.

One obstacle, though: cost. Attention compares every element with every other, so its cost grows as the square of the sequence length, a thousand points, a million comparisons; ten thousand points, a hundred million. And time series are long: one year of hourly readings is already 8,760 points (365 days × 24 hours). The first adaptations therefore focused on cutting that cost.

Where this page sits in the module

This lesson assumes the module's basics: what a time series is and its tasks (overview), the historical statistical methods (classical methods) and the first neural networks applied to curves (deep learning). Here begins the "Transformers" episode, the most eventful one.

Informer and Autoformer: adapting attention to long curves

Informer starts from an observation: in the attention computation, most comparisons are wasted, only a small fraction of positions really "look at" something specific; the rest spread their gaze uniformly. So Informer computes full attention only for the most "active" positions and handles the others cheaply. The paper's claim: a cost that grows almost linearly with length (as Llog⁡LL \log L, where LL is the sequence length, barely faster than proportionally), instead of the square.

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

Autoformer goes further and replaces attention outright with an auto-correlation mechanism: instead of comparing individual points, the model compares the curve with time-shifted copies of itself, discovering its periods (a 24-hour shift "fits" beautifully for a daily curve) and connecting the repeating segments. The model also progressively separates the curve into a slow trend and an oscillating seasonal part, an idea borrowed straight from classical statistics (see classical methods).

Autoformer: Decomposition Transformers with Auto-Correlation for Long-Term Series Forecasting
What to remember from these two papers

Two strategies against the same obstacle. Informer keeps attention but makes it frugal (compute only what matters). Autoformer replaces it with a mechanism tailored to curves (look for periods rather than links between points). In both cases the implicit assumption stands: "the Transformer is the right tool; it just needs adapting".

The twist: a linear layer beats everyone

In 2022, a paper with a deceptively innocent title (Are Transformers Effective for Time Series Forecasting?) lands like a cold shower.

Are Transformers Effective for Time Series Forecasting?

The authors build the simplest model imaginable, named DLinear: the curve is split into trend and seasonal parts (as in Autoformer), then each part goes through a single linear layer, a plain weighted combination of past points, with no attention, no depth, nothing. It is roughly the model a student would write in ten lines on day one.

Concretely, a linear layer does this: the forecast is a weighted sum of past points,

y^=w1x1+w2x2+⋯+wLxL\hat{y} = w_1 x_1 + w_2 x_2 + \dots + w_L x_L

where x1,…,xLx_1, \dots, x_L are the last LL observed points of the curve, y^\hat{y} is the predicted value, and w1,…,wLw_1, \dots, w_L are learned weights, fixed coefficients, set during training, that say how much each moment of the past counts in the forecast. In plain words: "the forecast is so much of yesterday's value, plus so much of the day before's, and so on". Nothing else.

Illustration of the basic linear model from the DLinear paper: a row of history points (History L timesteps) connected directly, through weighted connections, to a row of future points (Future T timesteps).
The cold-shower model, as drawn by its authors: every future point is a plain weighted sum of the past points. No attention, no depth, nothing but the direct connections visible in the diagram. This is the drawing that beat the Transformers on all nine datasets.Source : DLinear paper (figure 2), via the LTSF-Linear GitHub repository

The paper's verdict: on the nine real-world datasets tested (electricity, road traffic, weather, epidemics, exchange rates…), this tiny model beats the sophisticated Transformers in every case, often by a wide margin. Years of architectural refinement did worse than a well-tuned weighted sum.

Why? Temporal order gets lost along the way

The authors' explanation is the most interesting part of the paper. The attention mechanism is by nature insensitive to order: it treats the sequence as a bag of elements, where each one looks at the others based on content, not position. Shuffle the elements and the attention computation gives the same result, it is said to be permutation-invariant.

For text this is tolerable: words carry so much meaning on their own ("cat", "eats", "mouse") that much survives even in disorder, and a positional marker added to the inputs does the rest. But in a time series, an isolated point says almost nothing, 42.7 means nothing without knowing when. All the information is in the order: the rise, the fall, the rhythm. In other words, attention first throws out of the window precisely the information that matters most, then tries to patch it back in with positional band-aids. The linear layer never shuffles anything: the weight applied to the point from 24 hours ago stays attached to "24 hours ago".

The moral, and it is worth gold

An architecture that is prestigious in one field is not automatically superior in another. And an experimental result only has value when compared against the simple baseline: the dumb model you must beat to prove you are adding anything. Faced with an announcement claiming "our Transformer improves forecasting", the first question to ask is: improves over what? Did you compare against a plain linear regression? An entire literature got caught out for not doing so.

The comeback: PatchTST, or how to rehabilitate the Transformer

The story does not end in defeat. A year later, PatchTST shows that the problem was not the Transformer itself, but the way the curve was fed to it.

A Time Series is Worth 64 Words: Long-term Forecasting with Transformers (PatchTST)

Two changes, simple to state:

  • Patching: instead of feeding each measurement as an individual "token" (a sequence element), the curve is cut into slices of several dozen points, and each slice becomes one token. A token then carries a genuine local pattern (a rise, a peak, a dip) instead of a mute, isolated number. Attention compares shapes, not points; the order inside a slice is preserved mechanically, and there are far fewer tokens, hence far less computation. The paper's title says it all: a time series is worth 64 words.
  • Channel independence: when several quantities are tracked at once (temperature, pressure, vibration), each curve is processed separately, by the same model with the same weights, instead of being mixed into one joint input. Counter-intuitive (you would expect cross-referencing sensors to help) but more robust in practice.
PatchTST diagram: at the top, a multivariate series split into independent channels that each pass through the same Transformer; at the bottom, each univariate series is normalized, cut into patches, projected and fed to a Transformer encoder.
Both ingredients in a single diagram. At the top (a), channel independence: each curve goes through the same Transformer separately, and the outputs are then concatenated. At the bottom (b), patching: the series is normalized then cut into slices, and it is these slices (not isolated points) that the encoder compares.Source : PatchTST paper (figure 1), via the PatchTST GitHub repository

With these two ingredients, the paper reports that the Transformer moves back ahead of the linear models on the same benchmarks. The loop closes: attention was not useless, it was badly fed.

Recap: four papers, one soap opera

PaperCentral ideaStance on the TransformerVerdict
Informer (2020)Grant full attention only to the most "active" positionsAdapts it (makes it frugal)Later beaten by DLinear
Autoformer (2021)Replace attention with auto-correlation (find the periods) + trend/season decompositionTransforms itLater beaten by DLinear
DLinear (2022)A single linear layer, after trend/season decompositionRejects itBeats both predecessors everywhere
PatchTST (2022)Cut the curve into slice-tokens, process each variable separatelyRehabilitates itMoves back ahead of the linear models

Four papers in three years, each overturning the previous one. That is this field's normal pace, one more reason to distrust any ranking presented as final.

Note the symmetry: DLinear wins by removing sophistication, PatchTST wins it back by changing the representation without adding complexity to the model itself. In both cases, victory does not come from a bigger architecture.

How could a whole community get it wrong?

The question deserves asking, because the mechanism is generic and shows up in many other fields.

Each new paper compared itself… to the previous Transformers. Informer measured itself against earlier models, Autoformer against Informer, and so on: an incremental race where everyone improved on everyone, and nobody went back to check the starting point. The simple baseline (linear regression) had left the results tables long ago, deemed too obviously outdated to deserve a row.

Add a well-known publication bias: "we tried a sophisticated architecture and it works" publishes better than "the simple method is enough". The DLinear paper owed its impact precisely to breaking that convention.

Going to the source

The four papers of this saga are linked throughout the page. If you read only one, read Are Transformers Effective for Time Series Forecasting?: it is short, crystal clear, and its permutation-invariance argument can be followed with no mathematics at all.

What this controversy teaches

Beyond the anecdote, four lasting lessons:

  1. The field's standard benchmarks are small and idiosyncratic; a ranking obtained on them guarantees nothing elsewhere. The controversy in fact pushed the community to rethink its test sets.
  2. The input representation (how the data is cut up and presented) can matter more than the architecture itself. Patching, a modest-looking idea, flipped the ranking, exactly the kind of concrete building block that makes a defensible invention, far more than "we used a Transformer".
  3. Demanding the simple baseline is not academic politeness; it is the heart of the proof.
  4. A field can import a prestigious tool without checking that its assumptions hold in the new context. Attention assumes that sequence elements carry meaning on their own; true of words, false of measurement points. Spotting the hidden assumption that does not transfer is often where real understanding lives, and sometimes where the real invention lives.

Patching, the PatchTST ingredient, went on to become the standard component of time-series foundation models, one large model pre-trained on millions of curves, able to forecast a series it has never seen. That is the subject of the time-series foundation models lesson, which follows on directly from this one.

Key points

  1. Attention looked ideal for time series: it captures arbitrarily long dependencies (this Monday resembling past Mondays), where recurrent models run out of breath.
  2. Informer and Autoformer adapted the Transformer to the cost of long sequences: frugal attention for one, a period-seeking auto-correlation mechanism for the other.
  3. The twist (DLinear): a single linear layer beats these sophisticated Transformers on the standard benchmarks, because attention, being permutation-invariant, loses temporal order, precisely the information that matters in a curve.
  4. PatchTST rehabilitates the Transformer by changing how the data is presented: cut the curve into slice-tokens (patching) and process each variable separately.
  5. The moral, to carry everywhere: an architecture prestigious elsewhere is not superior by default, and an improvement is only proven against the simple baseline. Faced with any announcement, demanding that comparison is the right reflex.
Check your understanding0 / 5

1. According to the DLinear authors, why is attention poorly suited to a curve when it excels on text?

2. How does PatchTST rehabilitate the Transformer on the very same benchmarks?

3. How could a whole community publish Transformers for years that a linear layer beat?

4. A disclosure states: 'our Transformer improves forecasting by 8%.' What, per the page, is the first question to ask?

5. What symmetry does the page note between the successive victories of DLinear and then PatchTST?