timefs / README.md
siriuz42's picture
Update README.md
cb20a34 verified
|
raw
history blame
No virus
2.21 kB
metadata
license: apache-2.0

TimesFM (Time Series Foundation Model)

TimesFM is a pretrained time-series foundation model developed by Google Research for time-series forecasting.

Paper link: https://arxiv.org/abs/2310.10688 (to appear in ICML 2024)

Blog post: https://research.google/blog/a-decoder-only-foundation-model-for-time-series-forecasting/

This repo contains the code to load public TimesFM checkpoints and run model inference locally.

This is not an officially supported Google product.

Installation

We have two environment files. For GPU installation (assuming CUDA 12 has been setup), you can create a conda environment from the base folder through:

conda env create --file=environment.yml

For a CPU setup please use,

conda env create --file=environment_cpu.yml

followed 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,
  )
  1. 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.

  2. 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.

  3. We also provide an API to forecast from pandas dataframe. Please look at the documentation of the function tfm.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.