timesfm 2.0 500m jax
googleTimesFM 2.0-500M-JAX
Introduction
TimesFM (Time Series Foundation Model) is a pretrained model developed by Google Research for time-series forecasting. This model focuses on univariate time series forecasting with capabilities for handling context lengths up to 2048 time points. It supports point forecasts and offers experimental quantile heads, although they have not been calibrated after pretraining.
Architecture
The model is designed with a decoder-only architecture aimed at time-series forecasting. It requires the context to be contiguous and of the same frequency as the horizon. Missing values are filled using linear interpolation before model invocation. The model is equipped to perform with a maximum context length of 2048, though it can handle longer sequences in future updates.
Training
The TimesFM 2.0 series includes a pretraining set that combines datasets from TimesFM 1.0 and additional datasets from the LOTSA pretraining data. This extensive pretraining dataset allows the model to be benchmarked fairly against other models in the field.
Guide: Running Locally
Installation
To use TimesFM, clone the GitHub repository and install the TimesFM library for model inference by following the instructions in the PAX version.
Basic Usage
-
Initialize and Load Checkpoint:
import timesfm # For PAX tfm = timesfm.TimesFm( hparams=timesfm.TimesFmHparams( backend=<backend>, per_core_batch_size=32, horizon_len=128, input_patch_len=32, output_patch_len=128, num_layers=50, model_dims=1280, use_positional_embedding=False, ), checkpoint=timesfm.TimesFmCheckpoint( huggingface_repo_id="google/timesfm-2.0-500m-jax"), )
-
Inference:
- For array inputs:
import numpy as np forecast_input = [ np.sin(np.linspace(0, 20, 100)), np.sin(np.linspace(0, 20, 200)), np.sin(np.linspace(0, 20, 400)), ] frequency_input = [0, 1, 2] point_forecast, experimental_quantile_forecast = tfm.forecast( forecast_input, freq=frequency_input, )
- For pandas DataFrame:
import pandas as pd forecast_df = tfm.forecast_on_df( inputs=input_df, freq="M", # monthly value_name="y", num_jobs=-1, )
- For array inputs:
Cloud GPUs
For running computationally intensive tasks, consider using cloud-based GPU services such as AWS EC2, Google Cloud Platform, or Azure.
License
TimesFM is released under the Apache 2.0 license, allowing for open-source use and distribution with adherence to the license terms.