$ show google-research/timesfm
TimesFM is a pretrained decoder-only transformer foundation model for time-series forecasting, developed by Google Research. The repository provides multiple model versions (v1.0, v2.0, v2.5, v3.0) with implementations in PyTorch, Flax/JAX, and MLX (Apple Silicon). It supports zero-shot univariate and multivariate forecasting with covariates, quantile outputs, and various preprocessing options (RevIN normalization, linear detrending, symmetric averaging). The codebase includes a high-level forecaster API, CLI scripts for CSV forecasting and system checks, fine-tuning examples (LoRA/DoRA), and comprehensive benchmarks (GIFT-Eval, TIME, FEV). While primarily an application library, it also contains research-oriented components like benchmark runners and notebooks, making it a hybrid project with a strong application focus.
The LLM identified 5 files worth highlighting for reuse:
Implements MixingTransformer with separate sequence and variate attention mechanisms, Rotary Positional Embedding (RoPE), per-head QK RMSNorm, and PerDimScale. This architecture is a novel pattern for multivariate time series that can be extracted and reused in other transformer-based forecasting models.
Provides RevIN (Reversible Instance Normalization) with running statistics, RMSNorm, and PerDimScale layers. These are self-contained, framework-agnostic normalization modules that can be reused in any time series or deep learning project requiring adaptive normalization.
Implements CPM (Cross-Patch Memory) iterative RevIN refinement, a technique to improve forecast accuracy by iteratively adjusting normalization statistics across patches. This is a non-obvious, reusable pattern for enhancing RevIN-based forecasting.
Provides BatchedInContextXRegLinear for handling dynamic numerical, dynamic categorical, and static categorical covariates in time series forecasting. Includes one-hot encoding, ridge regression, and per-input normalization. This library can be extracted and used in any forecasting pipeline requiring covariate support.
A production-ready CLI script that reads a CSV file with time series data, applies TimesFM forecasting with configurable parameters (context length, horizon, quantiles, frequency), and outputs results to CSV. Demonstrates a clean, reusable pattern for wrapping a model API into a command-line tool.