GitHub Trending Repositories

google-research/timesfm

Author: google-research

Stars: 712 stars today

Description: TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting.

README

TimesFM

TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting.

This open version is not an officially supported Google product.

Latest Model Version: TimesFM 2.5

Archived Model Versions:

Update - June 5, 2026

Updated PyPI to timesfm=2.0.0. See Install.

Update - Apr. 9, 2026

Added fine-tuning example using HuggingFace Transformers + PEFT (LoRA) — see timesfm-forecasting/examples/finetuning/. Also added unit tests (tests/) and incorporated several community fixes.

Shoutout to @kashif and @darkpowerxo.

Update - Mar. 19, 2026

Huge shoutout to @borealBytes for adding the support for AGENTS! TimesFM SKILL.md is out.

Update - Oct. 29, 2025

Added back the covariate support through XReg for TimesFM 2.5.

Update - Sept. 15, 2025

TimesFM 2.5 is out!

Comparing to TimesFM 2.0, this new 2.5 model:

Since the Sept. 2025 launch, the following improvements have been completed:

  1. ✅ Flax version of the model for faster inference.
  2. ✅ Covariate support via XReg (see Oct. 2025 update).
  3. ✅ Documentation, examples, and agent skill (see timesfm-forecasting/).
  4. ✅ Fine-tuning example with LoRA via HuggingFace Transformers + PEFT (see timesfm-forecasting/examples/finetuning/).
  5. ✅ Unit tests for core layers, configs, and utilities (see tests/).

Install

From PyPI

```shell

Install the package with torch

pip install timesfm[torch]

Or with Flax

pip install timesfm[flax]

And when XReg is needed

pip install timesfm[xreg] ```

Local Install

  1. Clone the repository: shell git clone https://github.com/google-research/timesfm.git cd timesfm

  2. Create a virtual environment and install dependencies using uv: ```shell # Create a virtual environment uv venv

    Activate the environment

    source .venv/bin/activate

    Install the package in editable mode with torch

    uv pip install -e .[torch]

    Or with flax

    uv pip install -e .[flax]

    And when XReg is needed

    uv pip install -e .[xreg] ```

  3. [Optional] Install your preferred torch / jax backend based on your OS and accelerators (CPU, GPU, TPU or Apple Silicon).:

  4. Install PyTorch.

  5. Install Jax for Flax.

Code Example

```python import torch import numpy as np import timesfm

torch.set_float32_matmul_precision("high")

model = timesfm.TimesFM_2p5_200M_torch.from_pretrained("google/timesfm-2.5-200m-pytorch")

model.compile( timesfm.ForecastConfig( max_context=1024, max_horizon=256, normalize_inputs=True, use_continuous_quantile_head=True, force_flip_invariance=True, infer_is_positive=True, fix_quantile_crossing=True, ) ) point_forecast, quantile_forecast = model.forecast( horizon=12, inputs=[ np.linspace(0, 1, 100), np.sin(np.linspace(0, 20, 67)), ], # Two dummy inputs ) point_forecast.shape # (2, 12) quantile_forecast.shape # (2, 12, 10): mean, then 10th to 90th quantiles. ```

File Structure

📄 .gitattributes
📁 .github
📁 .github/workflows
📄 .github/workflows/main.yml
📄 .github/workflows/manual_publish.yml
📄 .gitignore
📄 AGENTS.md
📄 LICENSE
📄 README.md
📄 pyproject.toml
📄 requirements.txt
📁 src
📁 src/timesfm
📄 src/timesfm/__init__.py
📄 src/timesfm/configs.py
📁 src/timesfm/flax
📄 src/timesfm/flax/__init__.py
📄 src/timesfm/flax/dense.py
📄 src/timesfm/flax/normalization.py
📄 src/timesfm/flax/transformer.py
📄 src/timesfm/flax/util.py
📁 src/timesfm/timesfm_2p5
📄 src/timesfm/timesfm_2p5/timesfm_2p5_base.py
📄 src/timesfm/timesfm_2p5/timesfm_2p5_flax.py
📄 src/timesfm/timesfm_2p5/timesfm_2p5_torch.py
📁 src/timesfm/torch
📄 src/timesfm/torch/__init__.py
📄 src/timesfm/torch/dense.py
📄 src/timesfm/torch/normalization.py
📄 src/timesfm/torch/transformer.py
📄 src/timesfm/torch/util.py
📁 src/timesfm/utils
📄 src/timesfm/utils/xreg_lib.py
📁 tests
📄 tests/__init__.py
📄 tests/test_base_utils.py
📄 tests/test_configs.py
📄 tests/test_model_loading.py
📄 tests/test_torch_layers.py
📄 tests/test_torch_utils.py
📁 timesfm-forecasting
📄 timesfm-forecasting/SKILL.md
📁 timesfm-forecasting/examples
📁 timesfm-forecasting/examples/anomaly-detection
📄 timesfm-forecasting/examples/anomaly-detection/detect_anomalies.py
📁 timesfm-forecasting/examples/anomaly-detection/output
📄 timesfm-forecasting/examples/anomaly-detection/output/anomaly_detection.json
📄 timesfm-forecasting/examples/anomaly-detection/output/anomaly_detection.png
📁 timesfm-forecasting/examples/covariates-forecasting
📄 timesfm-forecasting/examples/covariates-forecasting/demo_covariates.py
📁 timesfm-forecasting/examples/covariates-forecasting/output
📄 timesfm-forecasting/examples/covariates-forecasting/output/covariates_data.png
📄 timesfm-forecasting/examples/covariates-forecasting/output/covariates_metadata.json
📄 timesfm-forecasting/examples/covariates-forecasting/output/sales_with_covariates.csv
📁 timesfm-forecasting/examples/finetuning
📄 timesfm-forecasting/examples/finetuning/README.md
📄 timesfm-forecasting/examples/finetuning/finetune_lora.py
📁 timesfm-forecasting/examples/global-temperature
📄 timesfm-forecasting/examples/global-temperature/README.md
📄 timesfm-forecasting/examples/global-temperature/generate_animation_data.py
📄 timesfm-forecasting/examples/global-temperature/generate_gif.py
📄 timesfm-forecasting/examples/global-temperature/generate_html.py
📁 timesfm-forecasting/examples/global-temperature/output
📄 timesfm-forecasting/examples/global-temperature/output/animation_data.json
📄 timesfm-forecasting/examples/global-temperature/output/forecast_animation.gif
📄 timesfm-forecasting/examples/global-temperature/output/forecast_output.csv
📄 timesfm-forecasting/examples/global-temperature/output/forecast_output.json
📄 timesfm-forecasting/examples/global-temperature/output/forecast_visualization.png
📄 timesfm-forecasting/examples/global-temperature/output/interactive_forecast.html
📄 timesfm-forecasting/examples/global-temperature/run_example.sh
📄 timesfm-forecasting/examples/global-temperature/run_forecast.py
📄 timesfm-forecasting/examples/global-temperature/temperature_anomaly.csv
📄 timesfm-forecasting/examples/global-temperature/visualize_forecast.py
📁 timesfm-forecasting/references
📄 timesfm-forecasting/references/api_reference.md
📄 timesfm-forecasting/references/data_preparation.md
📄 timesfm-forecasting/references/system_requirements.md
📁 timesfm-forecasting/scripts
📄 timesfm-forecasting/scripts/check_system.py
📄 timesfm-forecasting/scripts/forecast_csv.py
📁 v1
📄 v1/LICENSE
📄 v1/README.md
📄 v1/TROUBLESHOOTING.md
📁 v1/docs
📄 v1/docs/contributing.md
📁 v1/experiments
📁 v1/experiments/baselines
📄 v1/experiments/baselines/__init__.py
📄 v1/experiments/baselines/timegpt_pipeline.py
📁 v1/experiments/extended_benchmarks
📄 v1/experiments/extended_benchmarks/README.md
📄 v1/experiments/extended_benchmarks/run_timegpt.py
📄 v1/experiments/extended_benchmarks/run_timesfm.py
📄 v1/experiments/extended_benchmarks/tfm_extended_new.png
📄 v1/experiments/extended_benchmarks/tfm_results.png
📄 v1/experiments/extended_benchmarks/utils.py
📁 v1/experiments/long_horizon_benchmarks
📄 v1/experiments/long_horizon_benchmarks/README.md
📄 v1/experiments/long_horizon_benchmarks/run_eval.py
📄 v1/experiments/long_horizon_benchmarks/tfm_long_horizon.png
📁 v1/notebooks
📄 v1/notebooks/covariates.ipynb
📄 v1/notebooks/finetuning.ipynb
📄 v1/notebooks/finetuning_torch.ipynb
📁 v1/peft
📄 v1/peft/README.md
📄 v1/peft/finetune.py
📄 v1/peft/finetune.sh
📄 v1/peft/usage.ipynb
📄 v1/poetry.lock
📄 v1/pyproject.toml
📁 v1/src
📁 v1/src/adapter
📄 v1/src/adapter/__init__.py
📄 v1/src/adapter/dora_layers.py
📄 v1/src/adapter/lora_layers.py
📄 v1/src/adapter/utils.py
📁 v1/src/finetuning
📄 v1/src/finetuning/__init__.py
📄 v1/src/finetuning/finetuning_example.py
📄 v1/src/finetuning/finetuning_torch.py
📁 v1/src/timesfm
📄 v1/src/timesfm/__init__.py
📄 v1/src/timesfm/data_loader.py
📄 v1/src/timesfm/patched_decoder.py
📄 v1/src/timesfm/pytorch_patched_decoder.py
📄 v1/src/timesfm/time_features.py
📄 v1/src/timesfm/timesfm_base.py
📄 v1/src/timesfm/timesfm_jax.py
📄 v1/src/timesfm/timesfm_torch.py
📄 v1/src/timesfm/xreg_lib.py
📁 v1/tests
📄 v1/tests/test_data_loader.py
📄 v1/tests/test_timesfm.py
Back to Trending