license: apache-2.0
TimesFM
TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting.
Resources and Technical Documentation:
- Paper: A decoder-only foundation model for time-series forecasting, to appear in ICML 2024.
- Google Research blog
- GitHub repo
Authors: Google Research
This is not an officially supported Google product.
Installation
This Hugging Face repo hosts TimesFm checkpoints. Please visit our GitHub repo to install the timesfm
library for model inference.
We have two environment files. For GPU installation (assuming CUDA 12 has been setup), you can create a conda environment tfm_env
from the base folder through:
conda env create --file=environment.yml
For a CPU setup please use,
conda env create --file=environment_cpu.yml
to create the environment instead.
Follow by
conda activate tfm_env
pip install -e .
to install the package.
Usage
Then the base class can be loaded as,
import timesfm
tfm = timesfm.TimesFm(
context_len=<context>,
horizon_len=<horizon>,
input_patch_len=32,
output_patch_len=128,
num_layers=20,
model_dims=1280,
backend=<backend>,
per_core_batch_size=<batch_size>,
quantiles=<quantiles>,
)
tfm.load_from_checkpoint(
<checkpoint_path>,
checkpoint_type=checkpoints.CheckpointType.FLAX,
)
The context_len here can be set as the max context length of the model. You can provide shorter series to the
tfm.forecast()
function and the model will handle it. Currently the model handles a max context length of 512, which can be increased in later releases.The horizon length can be set to anything. We recommend setting it to the largest horizon length you would need in the forecasting tasks for your application. We generally recommend horizon length <= context length but it is not a requirement in the function call.
We also provide an API to forecast from
pandas
dataframe. Please look at the documentation of the functiontfm.forecast_on_df()
.
Benchmarks
Please look into the README files in the respective benchmark directories within experiments/
for instructions for running TimesFM on the respective benchmarks.