TimesFM — Google's pretrained decoder-only forecaster, used zero-shot.
timesfm package. TuiML ships no weights; timesfm fetches its own checkpoint from the Hugging Face Hub on first use. The package and the google/timesfm-2.5-200m-pytorch checkpoint are both Apache-2.0, which is compatible with TuiML's BSD-3-Clause license, so there is no usage restriction to accept.Classes
Zero-shot forecasting with Google's pretrained TimesFM checkpoint.
TimesFM is a time series foundation model: a decoder-only transformer pretrained on a corpus of roughly 100 billion real-world time points, so that it forecasts any univariate series it is shown without being trained on it. Your series is the context; the model emits a point forecast and a full set of decile quantiles for every future step in one forward pass. Nothing is estimated on your data -- fit only stores the context and loads the checkpoint, and all the cost lands in predict.
This wrapper targets TimesFM 2.5 (200M parameters), the PyTorch release with the continuous quantile head and a context window of up to 16k points.
__init__( self, checkpoint: str = 'google/timesfm-2.5-200m-pytorch', context_length: int = 1024, max_horizon: int = 128, infer_is_positive: bool = True, batch_size: int = 32) -> None, )
Overview
-
The last
context_lengthpoints are per-series normalised, so the
- The context is cut into non-overlapping input patches of 32 points;
- A stack of causal self-attention layers runs over the patch sequence --
- The final patch's representation is decoded by a second residual MLP
-
A continuous quantile head produces the deciles;
predict
predict_quantiles the whole set.Theory
TimesFM treats forecasting as next-patch prediction, the time series analogue of next-token prediction in a language model. With input patches \tilde{y}_1, \dots, \tilde{y}_N of length p and output patches of length h > p, the pretraining objective is the mean squared error of each output patch given all preceding input patches:
Making the output patch longer than the input patch is the design choice that matters: it cuts the number of autoregressive steps a long horizon needs, which both speeds up inference and limits error accumulation. Version 2.5 adds a quantile head trained with the pinball loss, giving calibrated deciles rather than a point alone.
Parameters
checkpoint
context_length
max_horizon
predict beyond it recompiles the model for the larger horizon, which costs a second or two once.
infer_is_positive
batch_size
Attributes
model_
timesfm.TimesFM_2p5_200M_torch.
series_
fit.
n_obs_
fit.
quantile_levels_
predict_quantiles.
compiled_horizon_
Notes
Requires pip install 'tuiml[foundation]', which pulls in timesfm and PyTorch. Importing TuiML and constructing this class work without either; only fit needs them.
Weights are not shipped by TuiML. On first use timesfm downloads the checkpoint (about 800 MB) from the Hugging Face Hub into ~/.cache/huggingface. Code and weights are Apache-2.0, compatible with TuiML's BSD-3-Clause, so there is no commercial-use restriction to accept.
Device: the upstream model picks CUDA when it is available and the CPU otherwise; there is no device knob to expose.
Saved models stay small. Pickling a fitted wrapper stores the context and the hyperparameters, never the checkpoint or its compiled state; the model is reloaded and recompiled from the Hugging Face cache on the first forecast after loading.
Complexity: fitting costs one checkpoint load plus a compile. Prediction is one decoder forward pass over n_{\text{context}} / 32 patches per 128-step chunk of horizon. A GPU is worth roughly an order of magnitude.
When to use TimesFMForecaster:
- A strong forecast with zero tuning, on a series you have not modelled
ChronosForecaster.
- Long contexts: the 16k-point window is far longer than Chronos-Bolt's.
- When you need calibrated deciles, not just a point.
ThetaForecaster or SARIMAXForecaster when you need a model you can inspect, exogenous regressors, or a CPU-only deployment without PyTorch.References
See Also
Constructing and inspecting the model needs no optional dependency:
>>> from tuiml.foundation import TimesFMForecaster
>>> model = TimesFMForecaster(context_length=512)
>>> model.context_length
512
>>> "max_horizon" in model.get_parameter_schema()
True
Fitting requires pip install 'tuiml[foundation]' and downloads the
checkpoint on first use:
>>> import numpy as np # doctest: +SKIP
>>> t = np.arange(200) # doctest: +SKIP
>>> y = 10 + 0.05 * t + np.sin(2 * np.pi * t / 12) # doctest: +SKIP
>>> model.fit(y).predict(steps=3).round(1) # doctest: +SKIP
array([20.5, 21. , 21.4])
>>> model.predict_quantiles(steps=3).shape # doctest: +SKIP
(3, 9)