Skip to content

[New Model] TimesFM-2.5 Foundation Model #2976

@daidahao

Description

@daidahao

A sub issue of #2933.

Is your feature request related to a current problem? Please describe.
In September, Google released TimesFM 2.5, a 200M-parameter pre-trained time series model, on GitHub and HuggingFace.

The model itself supports univariate series only. Google has recently added covariate support by using xreg (a wrapper for ridge regression at inference time).

TimesFM2.5 currently ranks second on GIFT-EVAL among single open-source models, after Chronos-2 (implemented in #2943 #2961). If implementing a TimesFM 2.5 is of interest of Darts, I am happy to contribute a PR.

Describe proposed solution
Porting TimesFM-2.5 to FoundationModel should be easy and requires no additional dependencies than those already included (huggingface_hub for downloading weights, safetensors for loading weights, and torch). However, supporting covariates could be a challenge:

In Google's repo, there are two modes for adding covariate support, aka, xreg_mode:

  • "xreg + timesfm" (default): fits a model on the residuals of the TimesFM forecast
  • "timesfm + xreg": fits a model on the targets then forecasts on the residuals via TimesFM

Either mode involves solving ridge regression on targets and covariates at inference time (see forecast_with_covariates() in timesfm_2p5_base.py). We might not be able to do so in Darts because this might cause data leakage in the same batch (e.g., when calling historical_forecasts()).

Instead, I suggest we use a linear head and a MSE loss with L2 regularization to train that head and mimic ridge regression.

Another potential challenge is of course fine-tuning #2964. Since fine-tuning would require a deterministic loss or a Quantile Regression, this may not be compatible with the MSE loss. I haven't thought a way to address the conflict. Perhaps we get rid of the MSE loss when fine-tuning is enabled but this would make the model behave differently than not fine-tuning.

Describe potential alternatives
A clear and concise description of any alternative solutions or existing features that might solve it.

Additional context
Overall, a few discussions points I can think of:

  • Should we support covariates for TimesFM-2.5?
  • If so, should we add a linear head and a MSE loss with L2 to train the head? Are there better ways of doing this without risking data leakage?
  • What modes would the model support ("xreg + timesfm", "timesfm + xreg", or both) and which is the default?
  • Should the model support fine-tuning? If so, would it be compatible with the MSE loss?

I've tried to reach out to Google about collaborations but they haven't responded. See google-research/timesfm#348. I will invite TimesFM-2.5 co-authors for discussions here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageIssue waiting for triaging

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions