- Introduced by
- Nie, Y. et al.
- Year
- 2023
- Type
- Transformer for time series forecasting
What does it do?
PatchTST is a Transformer for time series forecasting, introduced by Nie and colleagues in 2023.
It divides each series into short overlapping patches, treats each patch as one token, and models the channels of a multivariate series independently with a shared backbone. The design aims to reduce the cost of self-attention on long inputs while targeting long-horizon forecasts.
The intuition behind the method
Feeding a Transformer one time step at a time wastes attention on tiny, noisy fragments and scales badly with long histories. PatchTST instead groups consecutive points into short overlapping windows, called patches, and treats each patch as a single token, much as a sentence is read word by word rather than letter by letter. This gives each token a richer local view, shortens the sequence the attention mechanism must handle, and so keeps the cost of attention manageable on long input histories.
History
PatchTST was introduced by Nie and colleagues in a 2023 ICLR paper, 'A Time Series is Worth 64 Words: Long-term Forecasting with Transformers'. The paper proposes patching and channel-independent modelling for long-term forecasting with Transformers. Other Transformer models designed for long-term series forecasting, such as FEDformer (Zhou et al., 2022), belong to the same line of work.
When to use it
PatchTST suits forecasting of continuous time series with a long history, particularly when the forecast horizon is also long. Choose it when there is enough data to tune patch length and overlap and access to GPU computation for training. Informal rules of thumb put the lower end of usable length at roughly 200 observations, with overfitting becoming a greater concern below about 500 points. These figures are not validated thresholds and should be checked against your own data. Do not use it on short series, where there are few patches for attention to learn from and classical models such as ARIMA are usually easier to justify. For series in the intermediate range, comparing against tree-based baselines such as Random Forest is advisable.
Limitations and considerations
- Needs a fairly long series. Informal rules of thumb put the lower end near 200 points, with overfitting a greater concern below roughly 500. These figures are not validated thresholds.
- Patch length and overlap are sensitive settings that must be tuned to the data.
- Training is compute-intensive, and a GPU is recommended.
- As a deep model it offers little direct interpretability compared with ARIMA-style coefficients.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Patching shortens the token sequence, reducing the cost of self-attention compared with point-wise Transformers.
- A single linear head emits the whole forecast horizon, so multi-step output does not require step-by-step decoding.
- Channel-independent weight sharing keeps the network compact and can reduce overfitting on multivariate data.
- Patch length and overlap give direct control over how much local context each token carries.
Applications
- Long-horizon forecasting of a single continuous time series with a long history.
- Multivariate forecasting in which each channel is modelled with a shared backbone.
- Benchmarking against classical baselines such as ARIMA and tree-based models.
- Research comparisons of Transformer architectures for long-term forecasting.
How it works
How it works
The input series is sliced into overlapping patches, which are short contiguous segments of consecutive time steps, and each patch is embedded as one token. Patch length and overlap are tunable settings. Longer patches carry more local context per token, while grouping points into patches yields a shorter token sequence than a point-wise Transformer, which keeps the attention computation cheaper.
For a multivariate series, each channel (variable) is modelled on its own rather than mixed with the others at the input. The same Transformer backbone is shared across channels. Sharing weights keeps the model compact and can reduce overfitting, since the same parameters are fitted to every channel rather than a separate network per variable.
The patch tokens pass through a standard Transformer encoder, whose self-attention learns dependencies between patches. A linear head maps the encoded representation to the full forecast horizon, so the model predicts a block of future values at once rather than one step at a time.
Formula
\hat{y}_{t+1:t+h}Common pitfalls
- Applying it to short series where ARIMA or another classical model would be easier to justify.
- Leaving patch length and overlap at defaults instead of tuning them to the series.
- Training without a GPU and accepting a model that has not converged.
- Ignoring the overfitting risk on series shorter than about 500 observations.
- Evaluating on a randomly shuffled split, which lets information from the future leak into training.
Frequently asked questions
What is a patch in PatchTST?
A patch is a short contiguous segment of the series, a small window of consecutive time steps, that is embedded as a single token. Using patches instead of individual points shortens the sequence the attention mechanism handles and gives each token more local context.
Why model channels independently?
In multivariate data each variable (channel) is forecast with the same shared Transformer backbone rather than being mixed together. This keeps the model compact, can reduce overfitting, and means the same parameters are fitted to every variable.
How much data do I need?
There is no validated minimum length. Informal rules of thumb suggest roughly 200 observations as a lower end, with overfitting a greater concern below about 500 points. On very short series, classical methods such as ARIMA are usually the more defensible choice.
Do I need a GPU?
A GPU is recommended for training. As a deep Transformer, PatchTST is more compute-intensive than classical forecasting models, and patch length and overlap should be tuned to the data.
How should I judge the forecasts?
Use a chronological split: train on earlier data and test on a later holdout, or preferably use rolling-origin backtesting over several successive forecast origins. Report standard error metrics such as MSE or MAE on the held-out part, and compare against a naive forecast and a classical baseline such as ARIMA before relying on the model.
Related methods
Sources
Nie, Y., Nguyen, N. H., Sinthong, P. & Kalagnanam, J. (2023). A Time Series is Worth 64 Words: Long-term Forecasting with Transformers. ICLR.
Open publication referenceZhou, T., Ma, Z., Wen, Q., Wang, X., Sun, L. & Jin, R. (2022). FEDformer: Frequency Enhanced Decomposed Transformer for Long-term Series Forecasting. ICML.
Open publication reference