TimesFM: A Decoder-Only Foundation Model for Time-Series Forecasting

Machine Learning
Introduced by
Abhimanyu Das et al. (Google)
Year
2024
Type
Pre-trained decoder-only transformer for zero-shot time-series forecasting
Family
Time-series forecasting

What does it do?

TimesFM is a pre-trained decoder-only transformer for univariate time-series forecasting, introduced by Abhimanyu Das, Weihao Kong, Rajat Sen, and Yichen Zhou from Google in 2024.

It converts a context window into patch tokens and is trained on a corpus of real-world and synthetic time series. The model is designed to forecast series that were not part of its training data without task-specific fine-tuning.

The intuition behind the method

TimesFM applies the sequence-modelling idea behind language models to numerical time series. The historical context is cut into fixed-length patches, each patch becomes one token after a learned embedding, and a causal transformer lets each position attend only to earlier patches. A linear head then reads the final hidden state and outputs values over the forecast horizon H. Because the weights were pre-trained on many series, the same model can be applied to a new series directly, although how well this works for a given series has to be checked.

History

TimesFM was developed at Google and presented at ICML in 2024. It adapts the decoder-only pre-training approach used in language modelling to time-series forecasting. The model was pre-trained on a corpus of real-world and synthetic time series; the original paper describes the sources and scale of that corpus and should be consulted for those details before the zero-shot claims are judged.

When to use it

Choose TimesFM for univariate forecasting, especially when many series must be forecast at once and training a separate model for each is impractical, or when labelled history for a new series is short. It fits regularly sampled data whose patterns are reasonably stable within the context window. Avoid it for multivariate problems where cross-series dependencies drive the forecast, for very irregular or sparse observations that do not fill evenly sized patches, and where an interpretable mechanistic model is required. Chronos, Moirai and PatchTST are the related alternatives; compare them on held-out data from the target domain before committing to one.

Limitations and considerations

  • The model targets univariate input: each series is handled on its own, and the architecture as described does not represent cross-variable structure.
  • The stated formula assumes observations grouped into full, non-overlapping patches of length p, so irregular timestamps or gaps need preprocessing before the model can be applied.
  • Horizons longer than the output block H depend on a decoding procedure not covered by the formula given here, so the released implementation should be checked before planning long-horizon forecasts.
  • The pre-trained transformer is large, so deployment on edge or embedded hardware may be costly.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Zero-shot use: the pre-trained weights are applied to new series without per-series training, which is the stated design goal of the model.
  • Patch tokenization shortens the sequence the transformer must process, from T time steps to roughly T/p tokens, which lowers attention cost relative to point-level tokens.
  • Causal decoder-only attention ensures each patch representation depends only on earlier context, matching the forecasting setting in which future values are unknown at prediction time.
  • Pre-training on a corpus mixing real-world and synthetic series can expose the model to a wider range of temporal shapes than a single series provides.

Applications

  • Potential use in retail demand forecasting across many product series, where training a separate model for each series is impractical
  • Potential use in energy load and renewable generation forecasting
  • Potential use in forecasting economic indicators and asset prices
  • Potential use in monitoring patient vital-sign trajectories
  • Potential use in web traffic and cloud resource demand forecasting for capacity planning

How it works

How it works

1

The context window x of length T is split into non-overlapping blocks of length p, so each block holds p consecutive observations. Each block is one token, so the transformer processes roughly T/p tokens instead of T. Because self-attention cost grows with the square of the number of tokens, this shortening is a key computational effect of patching, and the patch length p sets how many raw time steps share a token.

Formula
\text{Given a context window } \mathbf{x} = (x_1, \ldots, x_T), \text{ the series is divided into non-overlapping patches of length } p, \text{ yielding tokens } \mathbf{P}_i = (x_{(i-1)p+1}, \ldots, x_{ip}) \in \mathbb{R}^p.
2

Each patch vector is mapped into the model's embedding space by a learned projection, and positional encodings are added so that the transformer can distinguish where each patch sits in the context. The exact form of this embedding block should be checked against the original paper before the formula is reused. This is an embedding step, not a trend, seasonal or residual decomposition of the series.

Formula
\text{Each patch token is projected into an embedding space via a linear layer } \mathbf{z}_i = W_e \mathbf{P}_i + \mathbf{b}_e, \text{ and positional encodings are added to capture temporal order.}
3

The embedded patches pass through causal self-attention, where query-key scores are scaled by the square root of d_k, normalised with a softmax, and used to weight the values. Causal (decoder-only) masking means each patch position attends only to itself and earlier patches, so no representation uses information from later patches. The formula is standard scaled dot-product attention; the causal restriction is what defines the decoder-only setting.

Formula
\text{A causal (decoder-only) transformer processes the embedded patch sequence:} \\ \text{Attention}(Q, K, V) = \text{softmax}\!\left(\frac{QK^\top}{\sqrt{d_k}}\right)V, \text{ where } Q, K, V \text{ are linear projections of the patch embeddings.}
4

The final hidden state h_T, which summarises the context up to the last patch, is passed through the linear map W_f h_T + b_f to give a block of H predicted values in one forward pass. In the formula given here, the output length is fixed by the head's dimension H. Forecasts beyond H depend on the decoding procedure of the released implementation, which should be checked before planning long horizons.

Formula
\text{A linear forecasting head maps the final transformer hidden state } \mathbf{h}_T \text{ to the prediction horizon } H: \\ \hat{\mathbf{y}} = W_f \mathbf{h}_T + \mathbf{b}_f, \quad \hat{\mathbf{y}} \in \mathbb{R}^H.

Common pitfalls

  • Applying the model channel by channel to multivariate data discards cross-variable correlations, because the architecture does not encode them.
  • Since the context is split into patches of length p, a very short context produces few tokens and leaves the head with little history for long-horizon forecasts.
  • Accepting zero-shot output without checking accuracy on held-out data from the target domain can hide systematic errors, since the model has no information about that domain beyond its pre-training.
  • The embedding operates on patch values after input scaling, so the scaling and missing-value handling used by the released inference code should be matched; differences in preprocessing change what each token encodes and can shift the forecasts.
  • Zero-shot accuracy on public benchmarks can be inflated if evaluation series overlap with the pre-training corpus, so independent held-out evaluation on the target domain is needed before relying on the model.

Frequently asked questions

Does TimesFM require fine-tuning to work on a new dataset?

No. TimesFM is designed for zero-shot forecasting, so it can produce predictions on a new time series without additional training. Whether adapting the model to a specific dataset improves accuracy is an empirical question, and it should be tested on held-out data from that domain before the model is relied upon.

How does patch tokenization differ from standard point-level time-series transformers?

Standard point-level transformers treat each time step as a token, so the sequence length equals the number of observations and attention cost grows with its square. Patch tokenization groups consecutive steps into fixed-size blocks before embedding, which reduces the number of tokens the transformer attends over. The trade-off is that each token summarises p time steps, so the patch length determines how much detail a single token carries.

Can TimesFM handle multivariate time series?

TimesFM in its original formulation targets univariate forecasting: each series is processed independently. While it can be applied channel-by-channel to multivariate data, it does not explicitly model cross-variable interactions. For tasks where inter-series correlations are important, multivariate-native models or additional adaptation strategies would be more appropriate.

Related methods

Sources

  1. Das, A., Kong, W., Sen, R., & Zhou, Y. (2024). A decoder-only foundation model for time-series forecasting. ICML.

    Open publication reference