AI Logic

Architectures

TTM (Tiny Time Mixers)

Updated:

Structure of TTM. The left shows the overall flow from input to forecast; the right shows the inside of the backbone, made of three levels

Background and overview

TTM (Tiny Time Mixers) is an architecture built on MLPs that is effective for time series data.

TTM uses an architecture called TSMixer as its main component, and TSMixer in turn uses the ideas of MLP-Mixer.

Since MLP-Mixer consists only of MLP blocks, TTM is also an MLP-based architecture.

Because it is MLP-based, its computational cost grows linearly with the context length, whereas that of the Transformer grows with the square of the context length. This makes TTM efficient for data with long-range temporal correlations.

One point to be careful about is that TTM always takes the past values of the series to be forecast (Targets) as input. Other series (Features; exogenous variables in the paper) can be added optionally, but TTM cannot be used for regression that estimates Targets from Features alone.

I once tried applying TTM to regression for time series forecasting, but could not get good results. If you want to use only Features as input and output Targets in a time series forecasting task, Transformer-based models are recommended.

Theory

Like the Transformer, it has an encoder (called the backbone in the paper) and a decoder, each with multiple layers. The decoder is a small TSMixer, about 10–20% of the size of the backbone.

Each layer of the encoder and decoder uses TSMixer blocks, and a TSMixer block performs MLP mixing three times.

Structure of TSMixer. The left shows the overall flow from input to forecast; the right shows the inside of an MLP mixer layer (three mixers: inter-patch, intra-patch, and inter-channel)

This mixing is implemented with two fully connected layers and mixes information across patches, across the features within a patch, and across channels. Channel mixing is optional, and you can choose whether to use it. This can be expected to improve forecasting accuracy.

In addition, each time information is mixed, gated attention is applied instead of the Transformer's self-attention.

Gated Attention is a simplified form of self-attention. While the Transformer's attention has three weight matrices, Gated Attention has only one.

Information in TTM flows as follows.

  1. Patch the input data.
    • Patching means splitting the input data along the time axis.
    • For example, if the time series has a temporal correlation of 10 steps, the patches must be at least 10 long.
  2. The patched data is passed to the encoder.
  3. Processing is repeated as many times as the number of encoder layers (a few layers by default).
  4. The output of the encoder is passed to the decoder.
  5. The decoder likewise repeats processing as many times as the number of decoder layers (a few layers by default). The processing is almost the same as in the encoder.
  6. The output of the decoder is passed to TTM's output head.
  7. The output head scales the output data.

PyTorch example

Show code
python
### Work in progress ###

FAQ

Q. What are the characteristics of this paper?
A.

It can keep the computational cost lower than the Transformer.

Q. How easy is it to implement?
A.

Compared with other architectures, it is a little more difficult for beginners. From an AI engineer's point of view, however, the code and paper are well organized, so implementing it should not be difficult.

Q. How much data is needed for training?
A.

In the zero-shot case, no data is needed for training. In the few-shot case, it can be tuned with a small dataset. Building it from the base model requires a large amount of data.

References

  1. Ekambaram, V., Jati, A., Dayama, P., et al. (2024). Tiny Time Mixers (TTMs): Fast Pre-trained Models for Enhanced Zero/Few-Shot Forecasting of Multivariate Time Series. NeurIPS 2024.
  2. Ekambaram, V., Jati, A., Nguyen, N., Sinthong, P., Kalagnanam, J. (2023). TSMixer: Lightweight MLP-Mixer Model for Multivariate Time Series Forecasting. KDD 2023.