← Explainer Library

Interactive Explainer

Time-Series Transformers, Patched

Long-horizon forecasting on an air-quality-flavoured signal, four ways: seasonal-naive baseline, ARIMA-flavour, LSTM, PatchTST. Slide the patch length, watch the forecast and RMSE change. Why PatchTST finally beat the LSTMs and where Mamba is taking it next.

Prelude

What's hard about time-series forecasting?

Three things make time series harder than a regular ML problem:

The slogan. Almost every time-series result you read in 2020-2022 was beaten by seasonal-naive. PatchTST (2023) was the first deep model to comfortably win across benchmarks — with a 50-line architecture: cut the sequence into ViT-style patches and run a transformer on the patch tokens.
Step 1

The four baselines you owe yourself

Step 2

The patch trick

The earlier wave of time-series transformers (Informer, Autoformer, FEDformer) treated each timestep as a token. At long context lengths this drowns the model in tokens and the $O(N^2)$ cost balloons. PatchTST groups every $P$ consecutive points into one token (just like ViT does with $P \times P$ patches of an image), reducing token count by $P\times$ and giving the model a slightly smoother view of local structure.

That's it. Patch length $P$ is the only real new hyperparameter. Channel-independence (predict each channel with the same shared transformer, so multivariate isn't forced into a giant vocabulary) is the second trick. The third — instance normalisation per series — handles distribution drift.

The PatchTST tokenisation. Sequence → patches → embeddings → transformer → forecast head.
Step 2½

Channel independence — the unintuitive choice

PatchTST predicts each variate $v$ using the same shared transformer, with no cross-variate attention until a final projection. Reasoning:

Empirically the two cover different regimes: PatchTST wins on univariate-ish panels with many time steps; iTransformer wins when cross-variate structure dominates.

Step 2¾

RevIN — the instance normalisation that fixes distribution drift

A time series usually has a non-stationary mean and variance. The classical fix is differencing or log-transforming; PatchTST's modern fix is Reversible Instance Normalization (Kim et al., 2022):

Standardise the input window using its own mean/variance. Run the model on the normalised series. Un-normalise the forecast with the same statistics. Three lines of code; consistently +1–2% horizon-RMSE improvement on benchmark splits. Critical for chartof-the-decade-quality results.

Step 3

Race the four models live

Below: a synthetic AQ-flavour signal (daily + weekly + noise + slow drift). Slide the horizon and patch length; all four models forecast and the RMSE updates.

Context (left) | true (faint, right) | four overlaid forecasts. The vertical line marks the forecast start.
Step 4

What 2024-2026 has taught us

Final takeaway. Time-series forecasting is no longer a "deep learning lost to seasonal-naive" punchline. PatchTST and Mamba make long-horizon forecasting practical with modest compute, and foundation models change the data-budget equation entirely. The most practical 2026 update to any forecasting stack.
Step 5

How to set up a forecasting evaluation that doesn't lie

Step 6

Reading list