ML Systems Lab Open interactive version →
Advanced 60 min read N-BEATSN-HiTSTFTPatchTSTtransformer

Neural Forecasting

N-BEATS, N-HiTS, TFT, PatchTST, when transformers lose to MLPs, foundation models

Electricity demand forecasting is the benchmark problem for neural time series methods: 1-year history, predict 24 hours ahead. A sequence of Transformer-based papers — Informer, Autoformer, FEDformer — each claimed state-of-the-art on this benchmark. Then a 2023 paper (Zeng et al.) showed that a single linear layer applied to the flattened lookback window outperforms all of them. The reason exposes a structural flaw: Transformer attention is permutation-equivariant. Attention scores are computed from pairwise content similarity — dot products of embeddings — not from temporal position. Shuffle the timestamps and performance barely changes. A model that ignores temporal order cannot model autocorrelation, trend, or seasonality.

Positional encodings are added but don't fix this — they make position part of the content, which still allows position-insensitive mixing.

N-BEATS and N-HiTS sidestep this entirely. N-BEATS uses MLP stacks with a doubly-residual architecture: each block produces a backcast (reconstruction of its input) and a forecast; the backcast is subtracted before the next block, so each block models only what previous blocks couldn't explain. N-HiTS extends this with hierarchical multi-rate sampling — a coarse stack captures trends from downsampled series, a fine stack captures high-frequency variation — which is the right inductive bias for the 24-hour-ahead problem where trend and daily cycle operate at different timescales.

The Temporal Fusion Transformer (TFT) is competitive despite using attention because it preserves temporal structure everywhere else. An LSTM encoder processes the sequence before attention, variable selection networks gate which features matter per timestep, and attention operates on LSTM outputs rather than raw timestamps. TFT wins when rich covariates exist — static entity features, known future inputs — and N-HiTS wins without them.

NOT this. "Transformer-based models always outperform ARIMA and classical methods." N-BEATS, TFT, and other deep learning methods win on long-horizon multi-step forecasting with many series. On short, well-behaved univariate series with fewer than 2 years of history, ARIMA with seasonal decomposition frequently wins. The M4 and M5 competitions showed that feature-engineering with LightGBM beats most neural methods on the aggregate leaderboard. The right question is not which neural architecture to use but whether any neural model beats a well-tuned statistical baseline — that comparison must include DLinear.

Key points

Takeaway

Transformer self-attention ignores temporal order by design, which is why DLinear outperforms Informer on standard benchmarks — always include DLinear as a baseline before claiming any neural forecasting win. N-HiTS retains temporal inductive bias through hierarchical multi-rate MLP stacks and beats N-BEATS on long horizons; TFT is competitive only when rich covariates exist. Foundation models win exactly one scenario: cold start with fewer than 30 observations per series.

Recap

Check your understanding

Q1. A colleague reports Informer beats ARIMA by 15% lower MSE on ETT. Which TWO checks are appropriate before trusting this result?

Q2. You need to forecast hourly electricity demand for 1000 substations, 168 hours ahead (one week). You have 3 years of historical data per substation. TFT vs N-HiTS vs SARIMA — which do you use and why?

Q3. You train a TimeGPT zero-shot model on a new domain (pharmaceutical sales) without fine-tuning. It performs worse than Holt-Winters. When would you expect a foundation model to outperform statistical methods, and what limits them?

Q4. What is the doubly residual architecture in N-BEATS and why does it improve forecasting over a plain deep MLP?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →