liveBook · Manning

TimesFM

As explained in Time Series Forecasting Using Foundation Models

TimesFM is a foundation model designed for deterministic time-series forecasting.

TimesFM is a deterministic foundation model for time-series point forecasting: it returns one predicted value for each future time step rather than a probability distribution or calibrated interval. This makes it useful when planning requires a definitive forecast, but unsuitable for anomaly detection, which depends on uncertainty quantification. section 7.0 section 7.1

The model uses a decoder-only transformer with contiguous, nonoverlapping input patches. Residual blocks embed the patches and map transformer outputs to predicted values, while positional encoding supplies sequence information. Longer output patches reduce autoregressive steps on long horizons: with 32-step inputs and 128-step outputs, a 256-step forecast requires two steps rather than eight. section 7.1.1

Figure 7.1 Architecture of TimesFM. The input series is patched and set to a residual block that maps the input patches to a vector. The residual block is a multilayer perceptron with one hidden layer and a skip connection. The output vector is added to positional encoding and sent to the decoder-only transformer. The output of the transformer is sent to another residual block that returns a sequence of predicted values.
A diagram of a diagram

Description automatically generated

Use the architecture diagram to trace patching, residual-block embeddings, positional encoding, decoder-only attention, and output reconstruction. section 7.1.1

TimesFM’s design and operating constraints shape how it should be applied:

  • Trains with mean squared error, which penalizes large forecasting errors more heavily. section 7.1 section 7.1.2
  • Pretrains on more than 207 million unique series and over 380 billion data points, dominated by web-traffic data from Wiki Pageviews and Google Trends. section 7.1.2
  • Handles multiple series independently rather than modeling their interdependence; supports exogenous features through an external regression model while forecasting one target series. section 7.2 section 7.4
  • Uses context lengths that must be multiples of 32 and cannot exceed 2,048 for the 2.0 checkpoint; longer inputs are truncated. section 7.2.1 section 7.2
  • Requires substantial local resources: the available 500-million-parameter model needs about 16 GB of RAM to load with dependencies. section 7.4

Zero-shot weekly-sales forecasting

Load the `google/timesfm-2.0-500m-pytorch` checkpoint with a 2,048-step context and eight-step horizon. Rename the input columns to `unique_id` and `ds`, convert `ds` to datetime, then call `forecast_on_df` with weekly frequency and `Weekly_Sales` as the target. The method returns predictions for each store. Experimental quantiles may create a plotted 90% interval, but they are uncalibrated and should not be treated as reliable uncertainty estimates. section 7.2.1

Fine-tuning is possible in principle but requires writing training and batch-processing loops in JAX, and available documentation is sparse. Zero-shot forecasting is therefore the more accessible workflow. Evaluate forecasts with cross-validation rather than treating a single prediction as proof of superiority; a CPU Colab run for a blog-traffic experiment took roughly 765 seconds. section 7.3 section 10.2.7

How Time Series Forecasting Using Foundation Models covers it

How deep it goes
Explains patching, residual blocks, decoder-only attention, pretraining, and application constraints, but defers fine-tuning implementation.
Examples
Uses weekly store sales, DataFrame forecasting, experimental intervals, and CPU cross-validation on daily blog visits.
What it assumes
Assumes Python and DataFrame preparation, while requiring JAX expertise only for fine-tuning rather than zero-shot use.
What you can do after
Apply it via the TimesFM Python interface to generate and cross-validate zero-shot forecasts from suitably structured univariate data.
How it connects
Connects deterministic forecasting with transformers, patching, exogenous features, cross-validation, and anomaly detection.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Time Series Forecasting Using Foundation Models. The section links point to the parts of the book it draws on.