How to Harness Tiny Time Mixers (TTMs) for Multivariate Time-Series Forecasting

Oct 28, 2024 | Educational

If you’re venturing into the realm of time-series forecasting, the Tiny Time Mixers (TTMs) developed by IBM Research is a game-changer. With less than 1 million parameters, these pre-trained models not only provide stellar performance but are also easy to use. This guide will walk you through how to implement TTMs efficiently.

What are Tiny Time Mixers?

TTMs are compact pre-trained models specifically designed for multivariate time-series forecasting. They have proven to outperform larger models with billions of parameters in terms of performance during zero-shot and few-shot forecasting. Whether you’re working on data with hourly or minutely resolutions, TTMs are tailored to deliver rapid and accurate forecasts.

Getting Started with TTMs

Before you dive into coding, it’s essential to set the stage. Follow these steps:

  • Ensure you have access to a GPU or a well-equipped laptop. TTM can perform on a machine with one GPU or even a suitable laptop!
  • Visit the Hyding Face Model Hub to access different model variants.
  • Examine the model releases based on your forecasting requirements. For instance, the 512-96 model is excellent for hourly and minutely forecasting.

Implementing the Model

Let’s break down the code to understand how to deploy the TTM models effectively. Think of your forecasting task like directing traffic at a busy intersection. Each TTM variant represents a traffic light that controls the flow of predictions based on the surrounding conditions. Depending on the context provided (last time points), you can adapt your traffic lights to predict how much traffic will flow ahead.


model = TinyTimeMixerForPrediction.from_pretrained(
                "https://huggingface.co/ibm/TTM", revision="main"
            )
# Do zeroshot
zeroshot_trainer = Trainer(
        model=model,
        args=zeroshot_forecast_args,
    )
zeroshot_output = zeroshot_trainer.evaluate(dset_test)
# Freeze backbone and enable few-shot or finetuning:
for param in model.backbone.parameters():
    param.requires_grad = False
finetune_forecast_trainer = Trainer(
        model=model,
        args=finetune_forecast_args,
        train_dataset=dset_train,
        eval_dataset=dset_val,
        callbacks=[early_stopping_callback, tracking_callback],
        optimizers=(optimizer, scheduler),
    )
finetune_forecast_trainer.train()
fewshot_output = finetune_forecast_trainer.evaluate(dset_test)

Model Capabilities

The TTM models can be employed for various forecasting scenarios:

  • Zeroshot Forecasting: You can apply the pre-trained model directly to your target data without further training.
  • Finetuned Forecasting: Improve the model accuracy by training it on a subset of your own data.
  • Exogenous and Categorical Data Infusion: The model can accept additional inputs to aid in predictions.

Troubleshooting Tips

If you encounter issues during implementation, consider the following troubleshooting steps:

  • Ensure all necessary libraries are installed and updated.
  • Check the paths and branch names when loading the model from the hub.
  • Standard scale your data independently for each channel using the toolkit provided. Refer to this data processing utility for assistance.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

By leveraging the powers of TTMs, you’re armed with an efficient forecasting tool without overwhelming computational demands. The models are not just incredibly versatile but also quick to implement, ensuring you don’t spend more time on setup than on deriving valuable insights from your data.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox