TL;DR
TimesFM is a time-series foundation model: one Transformer, pretrained once on a large corpus of time series, that forecasts datasets it has never seen without any training on them. The paper's claim is that its zero-shot forecasts come close to the accuracy of models trained separately for each dataset, and sometimes match them. The model reads patches of the series as tokens, predicts the next patch in one shot, and is far smaller than the language models it takes its inspiration from.
Builds on: A Time Series is Worth 64 Words: Long-term Forecasting with Transformers, Time-Series Patching, Transformer, Autoregressive Model · Leads to: a line of pretrained forecasters that are compared against this zero-shot baseline, and the question of whether such models need covariates and probabilistic outputs
Why it mattered
Most forecasting systems train one model per series or per dataset. A retailer, a grid operator or a hospital pharmacy then needs a data pipeline, training runs and tuning for each new series, which is slow and expensive. The paper asks whether a model pretrained on enough varied series can simply be used on a new one, the way a large language model is used on new text. Its answer is yes, at least on the public benchmarks it tests, and that result pushed pretrained forecasting into the same conversation as pretrained language models. Its design choices, patching and output patches longer than input patches, are the ones to compare against in later work.
The problem
Forecasting models face a problem that language models do not. Text has a fixed vocabulary and grammar, while a time series has no shared vocabulary: a sales curve, a river gauge and a heart rate have different scales, sampling intervals and seasonal periods. A foundation model also needs to accept any history length (the context), any horizon, and any granularity from minutes to years.
Data is the second obstacle. Language models train on huge volumes of public text, but there is no equally large public archive of time series with that diversity. The paper's first contribution is therefore a training corpus built from real and synthetic sources, and its second is an architecture that can be pretrained on that corpus efficiently.
Two prior routes did not solve this. Local models such as ARIMA and Prophet are fitted to each series. Global deep models such as DeepAR and N-BEATS are trained on many series, but they are still supervised, and they are used on the same datasets they were trained on, or fine-tuned on new ones. Work that used large language models directly, such as GPT-3 or LLaMA-2 as zero-shot forecasters, was reported to be much weaker than the paper's approach, even though those models are far larger.
How it works
The model turns a context into patches, runs a decoder-only Transformer over the patches, and writes the next output patch. The diagram shows one pass.
flowchart LR A[Context of raw values] --> B[Split into input patches] B --> C[Residual block turns each patch into a token] C --> D[Add positional encoding] D --> E[Causal Transformer layers] E --> F[Residual block writes the next output patch] F --> G[Feed predictions back for longer horizons]
Take a tiny instance: a context of 12 hourly readings, input patches of 4, output patches of 8, and a forecast of 16 readings. Every number is small enough to check by hand.
-
Cut the context into patches. The 12 readings become 3 contiguous patches of 4: readings 1 to 4, 5 to 8, and 9 to 12. Check: 12 readings divided by patch length 4 gives 3 tokens.
-
Turn each patch into a token. A residual block (a small multilayer perceptron with a skip connection) maps each 4-value patch to a vector of the model width. The vector gets a positional encoding that marks its slot in the sequence. Check: the sequence the Transformer sees is 3 tokens long, not 12.
-
Let each token see only the past. Causal attention lets token 2 read tokens 1 and 2, and token 3 read tokens 1, 2 and 3, but never a later token. The Transformer computes all three outputs in one parallel pass, the way a language model does during training. Check: the output for token 1 depends only on readings 1 to 4.
-
Predict the next 8 readings from each token. Output token 3 is mapped by an output residual block to readings 13 to 20, the next output patch. Each token predicts a whole block, not one value. Check: 8 predicted values, the next 8 readings after the 12 seen.
-
Extend the horizon by feeding predictions back. To forecast 16 readings, the model first writes readings 13 to 20, appends them to the context, and then writes readings 21 to 28. The forecast the user needs is 16 readings, so 2 passes of 8 cover it. Check: 16 divided by 8 is 2 passes. With output patches of 4 it would take 4 passes.
-
Train on all positions at once. The loss is the mean squared error between each predicted patch and the readings that actually followed it, averaged over every token in the batch. Check: a token that predicts 8 values contributes 8 squared errors, and the batch averages over all of them.
The one non-standard part of training is the masking. For each series, the training code draws a random number between 0 and and hides the first readings of the first patch. That single trick lets one batch teach the model to forecast from every context length from 1 up to the maximum, not only from multiples of the patch length.
The math
The task is a map from a context to a horizon. Let be the context, the horizon, and the forecast. The model is a function with
Step 1 in symbols: patches
With input patch length , the -th patch is , and a context of length gives tokens.
Step 2 in symbols: tokens
Each patch, multiplied element by element () by a mask that zeroes masked readings, goes through the input residual block and then gets a positional encoding:
Step 3 in symbols: causal attention
The Transformer output at token depends only on tokens up to :
where is 1 when every reading in patch is masked, so that fully masked patches are not attended to.
Step 4 in symbols: output patches
where is the output patch length. The paper lets be longer than ; that is what makes the step-count arithmetic in the examples work.
Step 6 in symbols: training loss
Worked examples
Suppose the maximum context is 512 and the input patch length is .
- Sample , so the first 4 readings of the first patch are hidden.
- The first output token now sees readings, not 32.
- The second output token sees the next patch in full, so it sees readings.
- Repeat for every from 0 to 31. The first output token then covers context lengths from 1 to 32, and the later tokens cover the rest.
Interpretation: the model is trained on every context length it will meet at inference, even though its patches are 32 long. Without the random mask, it would learn only the multiples of 32.
Forecast 256 future readings with a context of 256.
- With output patches of 32, each pass writes 32 readings, so the model needs passes.
- With output patches of 128, each pass writes 128 readings, so it needs passes.
- Each pass feeds its predictions back as context, so every extra pass is another chance for error to build up.
Interpretation: a longer output patch cuts the passes from 8 to 2, which is why the paper trains with outputs longer than inputs.
Compare two input patch lengths on the same 512-reading context. The cost of self-attention grows with the square of the token count.
- With : tokens. Attention compares every pair, so pairs.
- With : tokens, so pairs.
- Ratio: . The shorter patch needs sixteen times the attention work.
- The paper reports that trains almost twice as fast as , and that and give the best accuracy.
Interpretation: patching is what makes a long context affordable, and the patch length trades speed against accuracy. The paper picks 32 as the practical choice.
Try it: a 1,024-reading context with gives how many tokens, and how many pairs does attention compare? Answer: 32 tokens, and pairs.
Results
The paper evaluates zero-shot on three public groups that were held out from pretraining. The Monash archive has 30 datasets; filtering out those with missing values leaves 18, scored by mean MAE scaled by a naive last-value baseline and averaged with a geometric mean. TimesFM is the top model there. It is slightly better than N-BEATS, within statistical significance, it beats the supervised DeepAR, and it improves on the zero-shot LLMTime (GPT-3 with prompting) by more than 25 percent.
The Darts group has 8 univariate series. TimesFM is within statistical significance of the best methods, which are LLMTime and seasonal ARIMA. The paper notes that each series is a single time series, so classical methods are competitive, and that LLMTime may have seen these series in training, which it cannot rule out.
On four ETT datasets (ETTh1, ETTh2, ETTm1, ETTm2) at horizons 96 and 192, averaged over 8 tasks, TimesFM and the supervised PatchTST are the best, and the other long-horizon methods are clearly worse. The evaluation uses the last test window to keep the cost of LLM baselines manageable, so it is a narrower test than rolling validation.
Fine-tuning gives a separate result. With 10 percent of the ETT training data, the fine-tuned model's average MAE on ETTh1 is 0.426, against 0.525 for a GPT-2-based model (GPT4TS), 0.542 for PatchTST and 0.600 for DLinear. This is fine-tuned, not zero-shot, so it answers a different question.
Ablations add detail. Error falls steadily as training compute grows across model sizes of 17M, 70M and 200M parameters. Removing the synthetic data makes almost no difference on the hourly ETTh datasets, but it hurts on the 15-minute ETTm datasets and on Monash, where granularities such as quarterly and yearly are underrepresented.
Limits and tradeoffs
It is tempting to think a foundation model is always the best first choice. In fact the paper's gains are on public benchmarks, and on several of them the model is only within statistical significance of the best supervised method; a dataset-specific model with proper tuning can still win, and the paper's own fine-tuning results show the value of adapting the model.
It is tempting to think a longer output patch is always better. In fact the paper notes that a long output patch is hard for series shorter than the patch, such as monthly or yearly data, so the output length has to be chosen against the granularities in the corpus.
It is tempting to think covariates such as prices or weather are needed for good forecasts. The paper's model uses none, because large corpora with meaningful covariates are hard to find. It lists covariates and probabilistic output as open problems, and it describes simple ways to add covariates later.
| Choice | Benefit | Cost |
|---|---|---|
| Longer output patch | Fewer autoregressive passes | Hard for series shorter than the patch |
| Shorter input patch | More tokens, finer detail | Attention cost grows with the square of the token count |
| Synthetic data in the mix | Covers rare granularities | Extra data to generate and mix |
| Decoder-only training | One pass trains every position | Needs masking to cover all context lengths |
Reading guide
- Abstract and Section 1 (Introduction): needs Time Series Forecasting and the idea of Zero-Shot Learning. The claim to test is "close to supervised accuracy without training on the dataset."
- Section 2 (Related work): needs DeepAR: Probabilistic Forecasting with Autoregressive Recurrent Networks, N-BEATS: Neural Basis Expansion for Interpretable Forecasting and Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting for the supervised models it compares with, and Language Model for the LLM route.
- Section 3 (Problem definition): needs the notation for a context and a horizon, from Time Series Forecasting.
- Section 4 (Model architecture): needs A Time Series is Worth 64 Words: Long-term Forecasting with Transformers and Time-Series Patching for patching, Transformer and Autoregressive Model for decoder-only training, Positional Encoding and Residual Connection for the blocks, and Mean Squared Error for the loss. The masking paragraph is the subtle part.
- Section 5 (Pretraining details): the data sources and the mixing rule, which uses Instance Normalization for scaling each context.
- Section 6 (Empirical results): the three benchmark groups and the ablations. Check every number against the tables and figure captions.
- Appendix A.3 (Fine-tuning): the ETT results after fine-tuning on 10 percent of the training data. They are not zero-shot, so keep them apart from the zero-shot results.
- Appendix A.2 (Metrics): the MAE and the scaled aggregation used across datasets. Section 4 (Loss function) and Appendix A.1 (Limitations) describe the probabilistic variant the paper leaves open, which would use a quantile loss, see Quantile Regression.
Check yourself
QuestionWhat is the difference between zero-shot and supervised forecasting in this paper?Show answer
A supervised model is trained or tuned on the dataset it forecasts. A zero-shot model, such as TimesFM on the Monash, Darts and ETT benchmarks, is pretrained on other data and used on these datasets without any training on them. The paper's claim is that the zero-shot model comes close to supervised models that were trained for each dataset.
QuestionWith a context of 512 and input patch length 16, how many tokens does the Transformer see, and how does that compare with patch length 32?Show answer
With patch length 16, there are tokens. With patch length 32, there are tokens. The Transformer sees twice as many tokens with the shorter patch, so its attention costs about four times as much, since attention cost grows with the square of the token count.
QuestionA model with output patch 128 must forecast 384 readings. How many passes does it need, and what would change if the output patch were 32?Show answer
It needs passes. With output patch 32 it would need passes. Each extra pass feeds predictions back as context, so the shorter output patch gives more chances for errors to build up.
QuestionWhy does the paper add random masking of the first patch during training?Show answer
Because the model must forecast from any context length at inference, but patches are a fixed length. Without masking, it would only see context lengths that are multiples of the patch length. Hiding a random number of readings in the first patch lets every context length from 1 up to the maximum appear in training, so one batch covers them all.
Sources
- Das, A., Kong, W., Sen, R., Zhou, Y. A decoder-only foundation model for time-series forecasting. arXiv:2310.10688 (2023). https://arxiv.org/abs/2310.10688
- Nie, Y., Nguyen, N. H., Sinthong, P., Kalagnanam, J. A Time Series is Worth 64 Words: Long-term Forecasting with Transformers. arXiv:2211.14730 (2022). https://arxiv.org/abs/2211.14730