Re-using fine-tuned models
Learn how to save, fine-tune, list, and delete TimeGPT models to optimize forecasting.
Reusing previously fine-tuned TimeGPT models can help reduce computation time and costs while maintaining or improving forecast accuracy.
This guide walks you through the steps to save, fine-tune, list, and delete your TimeGPT models effectively.
1. Import packages
First, import all necessary Python packages and initialize the Nixtla client.
2. Load data
Load the forecasting dataset and prepare the train/validation split.
Below is an example of how the data looks:
unique_id | ds | y | |
---|---|---|---|
0 | H1 | 1 | 605.0 |
1 | H1 | 2 | 586.0 |
2 | H1 | 3 | 586.0 |
3 | H1 | 4 | 559.0 |
4 | H1 | 5 | 511.0 |
3. Zero-shot forecast
Generate a quick forecast without fine-tuning to serve as your baseline.
The specified horizon (h=48) exceeds the default optimal model horizon.
Shorter horizons can often yield more accurate forecasts.
Baseline evaluation result:
metric | TimeGPT |
---|---|
rmse | 1504.474342 |
4. Fine-tune the model
5. Further fine-tune the model
You can fine-tune an already fine-tuned model to improve performance even more:
Use the newly obtained model identifier to forecast:
Updated evaluation results:
metric | TimeGPT_first_finetune | TimeGPT_second_finetune |
---|---|---|
rmse | 1472.024619 | 1435.365211 |
Fine-tuning on top of your already fine-tuned model can yield consistent improvements in forecast quality.
6. List fine-tuned models
You can view a list of all your fine-tuned models:
id | created_at | created_by | base_model_id | steps | depth | loss | model | freq |
---|---|---|---|---|---|---|---|---|
468b13fb-4b26-447a-bd87-87a64b50d913 | 2024-12-30 17:57:31.241455+00:00 | user | my-first-finetuned-model | 10 | 3 | default | timegpt-1-long-horizon | MS |
my-first-finetuned-model | 2024-12-30 17:57:16.978907+00:00 | user | None | 10 | 1 | default | timegpt-1-long-horizon | MS |
7. Delete fine-tuned models
When you no longer need a model, you can delete it to keep your workspace tidy:
Deleting a fine-tuned model is irreversible. Make sure to back up any necessary information before removal.
Congratulations! You have successfully learned how to save, refine, and manage your fine-tuned TimeGPT models.
This workflow helps optimize your forecasting pipelines by leveraging previously generated insights.