TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting.
Python
chore: add Apache 2.0 license headers to timesfm3 files and update README
Yichen Zhoua863f0b036b8
diff --git a/README.md b/README.mdindex 78582c3..0c36cb9 100644--- a/README.md+++ b/README.md@@ -6,45 +6,69 @@ model developed by Google Research for time-series forecasting.* Paper:[A decoder-only foundation model for time-series forecasting](https://arxiv.org/abs/2310.10688),ICML 2024.+* <span style="color:red">(NEW!)</span> TimesFM 3.0 Checkpoint:+ [`google/timesfm-3.0-pytorch`](https://huggingface.co/google/timesfm-3.0-pytorch).* Checkpoints (up to 2.5):[TimesFM Hugging Face Collection](https://huggingface.co/collections/google/timesfm-release-66e4be5fdb56e960c1e482a6).-* TimesFM 3.0 Checkpoint:- [`google/timesfm-3.0-pytorch`](https://huggingface.co/google/timesfm-3.0-pytorch).-* [Google Research blog](https://research.google/blog/a-decoder-only-foundation-model-for-time-series-forecasting/) (New blog post for TimesFM 3.0 coming soon!).+* [Google Research blog](https://research.google/blog/a-decoder-only-foundation-model-for-time-series-forecasting/)+ (New blog post for TimesFM 3.0 coming soon!).* TimesFM in Google 1P Products:- * [BigQuery ML](https://cloud.google.com/bigquery/docs/timesfm-model): Enterprise level SQL queries for scalability and reliability.- * [Google Sheets](https://workspaceupdates.googleblog.com/2026/02/forecast-data-in-connected-sheets-BigQueryML-TimesFM.html): For your daily spreadsheet.- * [Vertex Model Garden](https://pantheon.corp.google.com/vertex-ai/publishers/google/model-garden/timesfm): Dockerized endpoint for agentic calling.+ * [BigQuery ML](https://cloud.google.com/bigquery/docs/timesfm-model):+ Enterprise level SQL queries for scalability and reliability.+ * [Google Sheets](https://workspaceupdates.googleblog.com/2026/02/forecast-data-in-connected-sheets-BigQueryML-TimesFM.html):+ For your daily spreadsheet.+ * [Vertex Model Garden](https://pantheon.corp.google.com/vertex-ai/publishers/google/model-garden/timesfm):+ Dockerized endpoint for agentic calling.This open version is not an officially supported Google product.**Latest Model Version:** TimesFM 3.0-**Previous Model Version:** TimesFM 2.5-**Archived Model Versions:**-- 1.0 and 2.0: relevant code archived in the subdirectory `v1`. You can `pip install timesfm==1.3.0` to install an older version of this package to load them.----+- 2.5: relevant code under `src/timesfm`.+- 1.0 and 2.0: relevant code archived in the subdirectory `v1`. You can `pip+ install timesfm==1.3.0` to install an older version of this package to load+ them.++--------------------------------------------------------------------------------## Update — August 2026**TimesFM 3.0 is out!**-TimesFM 3.0 introduces native **multivariate time-series forecasting**, flexible **covariate support** (both past-only and past-and-future covariates), superior zero-shot generalist capabilities, and top performance across all three major time-series foundation model benchmarks.+TimesFM 3.0 introduces native **multivariate time-series forecasting**, flexible+**covariate support** (both past-only and past-and-future covariates), superior+zero-shot generalist capabilities, and top performance across all three major+time-series foundation model benchmarks.### Key Highlights:-- **Native Multivariate & Univariate Forecasting with Covariates**: Seamlessly forecast multi-channel multivariate series as well as individual univariate series, with native support for past-only and past-and-future dynamic covariates without per-task tuning.-- **Top Benchmark Performance**:- - 🥇 **fev-bench**: **Rank #1 overall** across 100 diverse real-world forecasting tasks.- - 🥇 **TIME Benchmark**: **Rank #1 overall** across 50 domain datasets and 98 evaluation tasks.- - 🥇 **GIFT-Eval**: **Rank #1 among all foundation models**.----+- **Native Multivariate & Univariate Forecasting with Covariates**: Seamlessly+ forecast multi-channel multivariate series as well as individual univariate+ series, with native support for past-only and past-and-future dynamic+ covariates without per-task tuning.+- **Top Benchmark Performance**:+ - 🥇 **fev-bench**: **Rank #1 overall** across 100 diverse real-world+ forecasting tasks.+ - 🥇 **TIME Benchmark**: **Rank #1 overall** across 50 domain datasets and+ 98 evaluation tasks.+ - 🥇 **GIFT-Eval**: **Rank #1 among all foundation models**.++### License notice for pretrained weights++> **Important:** The TimesFM source code in this repository is licensed under+> Apache-2.0. However, for the time being, TimesFM 3.0 pretrained weights are distributed under the+> separate `timesfm-non-commercial-license-v1.0` license and are restricted to+> non-commercial, non-production use. Commercial or production use of the+> default pretrained weights is **not permitted**.++--------------------------------------------------------------------------------## Update - July 2, 2026-Updated PyPI to `timesfm=2.0.2`. See [Install](https://github.com/google-research/timesfm#from-pypi).+Updated PyPI to `timesfm=2.0.2`. See+[Install](https://github.com/google-research/timesfm#from-pypi).## Update - Apr. 9, 2026@@ -52,17 +76,22 @@ Added fine-tuning example using HuggingFace Transformers + PEFT (LoRA) — see[`timesfm-forecasting/examples/finetuning/`](timesfm-forecasting/examples/finetuning/).Also added unit tests (`tests/`) and incorporated several community fixes.-Shoutout to [@kashif](https://github.com/kashif) and [@darkpowerxo](https://github.com/darkpowerxo).+Shoutout to [@kashif](https://github.com/kashif) and+[@darkpowerxo](https://github.com/darkpowerxo).## Update - Mar. 19, 2026-Huge shoutout to [@borealBytes](https://github.com/borealBytes) for adding the support for [AGENTS](https://github.com/google-research/timesfm/blob/master/AGENTS.md)! TimesFM [SKILL.md](https://github.com/google-research/timesfm/tree/master/timesfm-forecasting) is out.+Huge shoutout to [@borealBytes](https://github.com/borealBytes) for adding the+support for+[AGENTS](https://github.com/google-research/timesfm/blob/master/AGENTS.md)!+TimesFM+[SKILL.md](https://github.com/google-research/timesfm/tree/master/timesfm-forecasting)+is out.## Update - Oct. 29, 2025Added back the covariate support through XReg for TimesFM 2.5.-## Update - Sept. 15, 2025TimesFM 2.5 is out!@@ -76,12 +105,14 @@ Comparing to TimesFM 2.0, this new 2.5 model:- gets rid of the `frequency` indicator.- has a couple of new forecasting flags.-Since the Sept. 2025 launch, the following improvements have been completed for TimesFM 2.5:+Since the Sept. 2025 launch, the following improvements have been completed for+TimesFM 2.5: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/`).+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@@ -95,28 +126,32 @@ pip install timesfm[torch]#### Local Install-1. Clone the repository:- ```shell- git clone https://github.com/google-research/timesfm.git- cd timesfm- ```+1. Clone the repository:++ ```shell+ git clone https://github.com/google-research/timesfm.git+ cd timesfm+ ```++2. Create a virtual environment and install with PyTorch:-2. Create a virtual environment and install with PyTorch:- ```shell- # Using uv- uv venv- source .venv/bin/activate-- # Install the package in editable mode with torch- uv pip install -e .[torch]- ```+ ```shell+ # Using uv+ uv venv+ source .venv/bin/activate----+ # Install the package in editable mode with torch+ uv pip install -e .[torch]+ ```++--------------------------------------------------------------------------------### Code Examples: TimesFM 3.0#### 1. Univariate Forecasting (Variable Lengths)-Pass a batch of 1D NumPy arrays of different context lengths to forecast univariate time series:++Pass a batch of 1D NumPy arrays of different context lengths to forecast+univariate time series:```pythonimport numpy as np@@ -145,7 +180,9 @@ print("Series 2 quantiles shape:", outputs[1].quantiles.shape) # (12, 9)```#### 2. Multivariate Forecasting with Covariates-Pass a 2D array of shape `(num_variates, context_length)` along with optional past-only and past-and-future covariates:++Pass a 2D array of shape `(num_variates, context_length)` along with optional+past-only and past-and-future covariates:```pythonimport numpy as npdiff --git a/src/timesfm3/__init__.py b/src/timesfm3/__init__.pyindex ff741bf..da70af8 100644--- a/src/timesfm3/__init__.py+++ b/src/timesfm3/__init__.py@@ -1,4 +1,4 @@-# Copyright 2025 Google LLC+# Copyright 2026 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.@@ -18,20 +18,20 @@ from .configs import ResidualBlockConfig, StackedTransformersConfig, Transformerfrom .evaluator import TimesFM3Evaluatorfrom .model import TimesFM3Torchfrom .timesfm3_forecaster import (- ForecastOutput,- ModelConfig,- TimesFM3Forecaster,- _ModelConfig,+ ForecastOutput,+ ModelConfig,+ TimesFM3Forecaster,+ _ModelConfig,)__all__ = [- "ForecastOutput",- "ModelConfig",- "ResidualBlockConfig",- "StackedTransformersConfig",- "TimesFM3Evaluator",- "TimesFM3Forecaster",- "TimesFM3Torch",- "TransformerConfig",- "_ModelConfig",+ "ForecastOutput",+ "ModelConfig",+ "ResidualBlockConfig",+ "StackedTransformersConfig",+ "TimesFM3Evaluator",+ "TimesFM3Forecaster",+ "TimesFM3Torch",+ "TransformerConfig",+ "_ModelConfig",]diff --git a/src/timesfm3/configs.py b/src/timesfm3/configs.pyindex 657c579..62caa42 100644--- a/src/timesfm3/configs.py+++ b/src/timesfm3/configs.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Abstract configs for TimesFM-3 layers."""import dataclassesdiff --git a/src/timesfm3/cpm_revin_refine.py b/src/timesfm3/cpm_revin_refine.pyindex 30603ff..c2efcd4 100644--- a/src/timesfm3/cpm_revin_refine.py+++ b/src/timesfm3/cpm_revin_refine.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Standalone iterative RevIN refinement for CPM-masked patches in PyTorch.Extracted so it can be tested independently of the TimesFM3 model.diff --git a/src/timesfm3/cpm_revin_refine_test.py b/src/timesfm3/cpm_revin_refine_test.pyindex c8be5aa..797e798 100644--- a/src/timesfm3/cpm_revin_refine_test.py+++ b/src/timesfm3/cpm_revin_refine_test.py@@ -1,4 +1,4 @@-# Copyright 2025 Google LLC+# Copyright 2026 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.diff --git a/src/timesfm3/dense.py b/src/timesfm3/dense.pyindex f4c9933..0184d2d 100644--- a/src/timesfm3/dense.py+++ b/src/timesfm3/dense.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Dense layers for TimesFM3 PyTorch (inference only)."""from __future__ import annotationsdiff --git a/src/timesfm3/evaluator.py b/src/timesfm3/evaluator.pyindex aa29df8..544ec5b 100644--- a/src/timesfm3/evaluator.py+++ b/src/timesfm3/evaluator.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Evaluator subclass extending TimesFM3Forecaster for benchmark evaluation."""from __future__ import annotationsdiff --git a/src/timesfm3/model.py b/src/timesfm3/model.pyindex 73638c6..e30f518 100644--- a/src/timesfm3/model.py+++ b/src/timesfm3/model.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""TimesFM3 PyTorch model (inference only).Supports:diff --git a/src/timesfm3/model_test.py b/src/timesfm3/model_test.pyindex e36d893..91861ff 100644--- a/src/timesfm3/model_test.py+++ b/src/timesfm3/model_test.py@@ -1,4 +1,4 @@-# Copyright 2025 Google LLC+# Copyright 2026 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.diff --git a/src/timesfm3/normalization.py b/src/timesfm3/normalization.pyindex 6f20c5a..6321f1a 100644--- a/src/timesfm3/normalization.py+++ b/src/timesfm3/normalization.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Normalization layers for TimesFM3 PyTorch."""from __future__ import annotationsdiff --git a/src/timesfm3/primitives_test.py b/src/timesfm3/primitives_test.pyindex c7fdc9d..edac60f 100644--- a/src/timesfm3/primitives_test.py+++ b/src/timesfm3/primitives_test.py@@ -1,4 +1,4 @@-# Copyright 2025 Google LLC+# Copyright 2026 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.diff --git a/src/timesfm3/timesfm3_forecaster.py b/src/timesfm3/timesfm3_forecaster.pyindex 58c5e7e..cd3f0fc 100644--- a/src/timesfm3/timesfm3_forecaster.py+++ b/src/timesfm3/timesfm3_forecaster.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Forecaster API wrapping a pretrained TimesFM3 PyTorch model."""from __future__ import annotationsdiff --git a/src/timesfm3/timesfm3_forecaster_test.py b/src/timesfm3/timesfm3_forecaster_test.pyindex e08bf63..078866e 100644--- a/src/timesfm3/timesfm3_forecaster_test.py+++ b/src/timesfm3/timesfm3_forecaster_test.py@@ -1,4 +1,4 @@-# Copyright 2025 Google LLC+# Copyright 2026 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.diff --git a/src/timesfm3/transformations.py b/src/timesfm3/transformations.pyindex c25da83..85e08d0 100644--- a/src/timesfm3/transformations.py+++ b/src/timesfm3/transformations.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Reversible transformations for time-series models (PyTorch).Direct port of the Flax transformations.py: signed_log, signed_sqrt, identity.diff --git a/src/timesfm3/transformer.py b/src/timesfm3/transformer.pyindex 9811fd3..9f918a0 100644--- a/src/timesfm3/transformer.py+++ b/src/timesfm3/transformer.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Transformer layers for TimesFM3 PyTorch (inference only).Port of the Flax MixingTransformer architecture:diff --git a/src/timesfm3/transformer_test.py b/src/timesfm3/transformer_test.pyindex 2498cdf..26bc41c 100644--- a/src/timesfm3/transformer_test.py+++ b/src/timesfm3/transformer_test.py@@ -1,4 +1,4 @@-# Copyright 2025 Google LLC+# Copyright 2026 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.diff --git a/src/timesfm3/util.py b/src/timesfm3/util.pyindex 5c303fe..cc3d7ef 100644--- a/src/timesfm3/util.py+++ b/src/timesfm3/util.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Utility functions and classes for TimesFM3 PyTorch implementation."""from __future__ import annotationsdiff --git a/timesfm3-usage/benchmarks/fev_bench/run_fev_bench.py b/timesfm3-usage/benchmarks/fev_bench/run_fev_bench.pyindex 03f0858..f665768 100644--- a/timesfm3-usage/benchmarks/fev_bench/run_fev_bench.py+++ b/timesfm3-usage/benchmarks/fev_bench/run_fev_bench.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Direct runner for executing fev_bench_timesfm3.ipynb sequentially."""import osdiff --git a/timesfm3-usage/benchmarks/gift_eval/evaluate_all_gift.py b/timesfm3-usage/benchmarks/gift_eval/evaluate_all_gift.pyindex ad50258..45f2c26 100644--- a/timesfm3-usage/benchmarks/gift_eval/evaluate_all_gift.py+++ b/timesfm3-usage/benchmarks/gift_eval/evaluate_all_gift.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Official Full GIFT-Eval Benchmark Evaluator for TimesFM 3.0 (All 97 Configurations)."""import osdiff --git a/timesfm3-usage/benchmarks/time_bench/run_time_bench.py b/timesfm3-usage/benchmarks/time_bench/run_time_bench.pyindex 730ab17..68fa014 100644--- a/timesfm3-usage/benchmarks/time_bench/run_time_bench.py+++ b/timesfm3-usage/benchmarks/time_bench/run_time_bench.py@@ -1,3 +1,17 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Direct runner for executing time_bench_timesfm3.ipynb sequentially."""import os