                                               In-Context Fine-Tuning for Time-Series Foundation Models


Table 1. MAE of TimesFM-ICF against other supervised and zero-shot methods on ETT Rolling Window, averaged over forecast horizons
{96, 192, 336, 720}. See Table 9 for a detailed breakdown. We bold the numbers which are the best in every row, and including the ones
that are within standard error of the best.
            Few-shot                               Zero-shot                                                                        Task-specific
           TimesFM-ICF   TimesFM (Base)   Moirai (Small)   Moirai (Base)   Moirai (Large)   TimesFM-FT   iTransformer   TimesNet   PatchTST    Crossformer   DLinear   SCINet   FEDformer
 Dataset
 ETTh1           0.405            0.417           0.424           0.438            0.469         0.407         0.447       0.450      0.454          0.522     0.452    0.647       0.460
 ETTh2           0.378            0.396           0.379           0.382            0.377         0.381         0.407       0.497      0.407          0.683     0.515    0.723       0.449
 ETTm1           0.378            0.391           0.410           0.388            0.389         0.371         0.410       0.406      0.400          0.495     0.407    0.481       0.452
 ETTm2           0.307            0.329           0.341           0.321            0.320         0.306         0.332       0.332      0.326          0.610     0.401    0.537       0.349




                                                                                                 This shows that our technique of in-context fine-tuning can
                                                                                                 be more effective than training a longer history model, espe-
                                                                                                 cially when there is a mix of short-history and long-history
                                                                                                 time-series. This is because, for in-context fine-tuning,
                                                                                                 many short time-series can be packed as in-context exam-
                                                                                                 ples inside the context, while for the case of usual long
                                                                                                 history training such time-series will just be padded and
                                                                                                 most of the context is wasted. As shown in the detailed
                                                                                                 results in Table 6, the long history model performs at par
                                                                                                 or very slightly better on longer datasets like ERCOT, but
                                                                                                 degrades on shorter datasets like CIF and Toursim.
Figure 6. Scaled MASE (GM) vs number of in-context examples
over the short context datasets in the OOD Benchmark. We also                                    7. Conclusions
plot the total inference time for all the datasets as we vary the
number of examples. All numbers are averaged over 5 runs with                                    In this paper, we introduce a methodology for in-context
the corresponding one standard error.                                                            fine-tuning of a time-series foundation model for forecast-
                                                                                                 ing. In particular, we start with a base foundation model and
                                                                                                 adapt it to be able to effectively utilize, at inference time,
the standard error bars are reported. We can see that the                                        not just the history of the target time-series for forecasting,
error decreases monotonically as the number of in-context                                        but also in-context examples from related time-series. Our
examples are increased. At the same time, the total inference                                    results show that in-context fine-tuning can lead to signifi-
time increases, signifying a trade-off.                                                          cantly better zero-shot performance on popular forecasting
                                                                                                 benchmarks compared to the base foundation model and
6.4.2. L ONGER H ISTORY                                                                          state-of-the-art supervised models. Furthermore, it even
In this section, we compare the performance of TimesFM-                                          matches the performance of a version of the base foundation
ICF with a modified version of TimesFM (base) pretrained4                                        model that is explicitly fine-tuned on the target domain.
and evaluated with a longer history L = 2048 which we will                                       While we have chosen a specific base time-series foundation
refer to as TimesFM (LH). We provide the aggregate scaled                                        model (TimesFM) for our in-context fine-tuning approach,
MASE on the OOD Benchmark in Table 2. We restrict                                                it would be an interesting direction of future work to study
TimesFM-ICF to use at most 5 in-context examples (of                                             these adaptations for other base foundation models. It would
length 512 each), so it is a fair comparison.                                                    also be interesting to study better forms of relative positional
                                                                                                 encodings specifically designed for handling in-context ex-
 Dataset                 TimesFM-ICF         TimesFM (LH)           TimesFM (base)               amples and length generalization.
 OOD Benchmark               0.777                 0.811                   0.834

Table 2. Comparison with longer context TimesFM (LH) model,
                                                                                                 Impact Statement
which has a maximum history of 2048. We report the Scaled                                        This paper presents work whose goal is to advance the field
MASE (GM) on the OOD Benchmark.                                                                  of Machine Learning. There are many potential societal
                                                                                                 consequences of our work, none which we feel must be
We can see that TimesFM (LH) yields a modest 2.4% im-                                            specifically highlighted here.
provement over TimesFM (base) (maximum history of 512)
while TimesFM-ICF yields a 6.8% improvement.
    4
      Pretraining performed in a manner similar to the latest version
of the TimesFM Hugging Face repo.

                                                                                             8
