Skip to content
Log inGet startedHugging FaceGitHub

Going further

Fine-tuning

If your series follow patterns of their own, such as your promotions or paydays, tune adapts the model to your history. It takes seconds to a few minutes on a CPU, and the original model is left unchanged.

tuned = model.tune(df, h=7)
tuned.report # how the tune did on your held-out history
fc = tuned.forecast(df, h=7)
  1. The last h steps of each series are held out.
  2. Small adapters are trained on the rest of your history, with the pretrained weights frozen.
  3. The tuned model is kept only if it forecasts the held-out steps better than the pretrained model, by 2% by default. Otherwise you get the pretrained model back, with a warning.
  4. The tune is then retrained on the whole history and merged into a copy of the weights, so a tuned model forecasts as fast as the original.
  • h: the horizon you will forecast; it is also the length of the held-out part.
  • steps: training steps (default 300).
  • min_gain: how much better the tune must be on the held-out steps to be kept (default 0.02).
  • preset, cross_series: the forecast settings the tune is checked with. Use the ones you will forecast with.
  • past, known and the column names work as in forecast.

tuned.report says whether the tune was kept (used), the held-out loss and WAPE of the pretrained and the tuned model, how many steps were kept, and how long it took.

tuned.save("my-tuned/")
model = ChakraTS.from_pretrained("my-tuned/")

The folder holds the weights, the config and the model’s license files. A tuned model stays under the license of the model it was tuned from, and save writes a notice saying it was modified.