--- 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](https://arxiv.org/abs/2310.10688), to appear in ICML 2024. * [Google Research blog](https://research.google/blog/a-decoder-only-foundation-model-for-time-series-forecasting/) * [GitHub repo](https://github.com/google-research/timesfm) **Authors**: Google Research This is not an officially supported Google product. ## Installation This Hugging Face repo hosts TimesFm checkpoints. Please visit our [GitHub repo](https://github.com/google-research/timesfm) 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, ```python import timesfm tfm = timesfm.TimesFm( context_len=, horizon_len=, input_patch_len=32, output_patch_len=128, num_layers=20, model_dims=1280, backend=, per_core_batch_size=, quantiles=, ) tfm.load_from_checkpoint( , 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.