UniTS: A Unified Multi-Task Time Series Model

Shanghua Gao, Teddy Koker, Owen Queen, Thomas Hartvigsen, Theodoros Tsiligkaridis, Marinka Zitnik

In the world of AI, "Foundation Models" like GPT-4 or CLIP have changed the game by performing dozens of tasks with a single set of weights. However, the world of time series data—think heart rate monitors, stock prices, and weather sensors—has remained stubbornly fragmented. Until now, if you wanted to forecast the weather and classify an ECG heartbeat, you needed two completely different model architectures.

A new paper from researchers at Harvard and MIT, titled "UniTS: A Unified Multi-Task Time Series Model," introduces a breakthrough: a single transformer-based model that handles forecasting, classification, imputation, and anomaly detection across dozens of different domains without changing its internal structure.

TL;DR

UniTS is a unified foundation model for time series that integrates both generative (forecasting) and predictive (classification) tasks into one framework. By using a novel "task tokenization" approach and a flexible transformer architecture, it outperforms specialized models across 38 diverse datasets while being significantly smaller and faster than adapted Large Language Models (LLMs).

UniTS processes diverse time series data across multiple domains and tasks using a single unified model.

What Problem Does This Paper Address?

Time series data is notoriously messy. Unlike text, which follows a standard vocabulary, time series data varies wildly in:

  1. Dimensions: One dataset might have a single sensor (univariate), while another has hundreds (multivariate).
  2. Frequency: Data might be recorded every millisecond or every hour.
  3. Task Requirements: Forecasting requires generating new data points (generative), while classification requires a discrete label (predictive).

Most existing models are "narrow experts." A model designed for forecasting usually cannot be used for anomaly detection without massive architectural changes. Even recent attempts to "reprogram" text-based LLMs for time series are computationally expensive and often require task-specific "heads" (output layers) for every new dataset.

Methods: Task Tokenization and a Unified Architecture

The secret sauce of UniTS lies in treating everything as a token-processing problem, eliminating the need for task-specific output layers.

The UniTS architecture utilizes task tokenization and a specialized transformer block to handle both generative and predictive tasks.

1. Task Tokenization

UniTS uses three distinct types of tokens to standardize inputs and outputs:

  • Sample Tokens: Patches of the actual time series data.
  • Prompt Tokens: Learnable embeddings that provide context about the specific dataset or domain.
  • Task Tokens: GEN tokens are used for generation (forecasting, imputation), while CLS tokens are used for classification. To classify, the model compares the output CLS token to "class embeddings" using distance matching, meaning the model doesn't need a fixed-size final layer.

2. The UniTS Block

The model uses a modified Transformer block designed for heterogeneity:

  • Two-way Self-Attention: It attends to both the time dimension and the variable dimension simultaneously, allowing it to capture inter-dependencies between different sensors.
  • Dynamic Linear (DyLinear): Standard neural network layers have fixed input sizes. UniTS uses "weight interpolation" to dynamically resize its layers, allowing it to process sequences of any length.
  • Gating Modules: These act as traffic controllers, preventing "interference" when the model is trained on many different types of data at once.

Key Insights and Results

The researchers put UniTS through a grueling "decathlon" of testing across 38 datasets spanning healthcare (ECG/EEG), finance, electricity, weather, and human activity sensors. They tested against 12 forecasting, 20 classification, 18 anomaly detection, and 16 imputation models.

  • Multi-Task Mastery: In the most difficult setting—one model for 38 tasks—UniTS excelled in 27 out of 38 tasks, proving that a single shared-weight model can master diverse domains.
  • Forecasting and Classification: UniTS-ST (single-task version) achieved the best results on 28 out of 32 forecasting benchmarks, significantly beating the previous state-of-the-art, iTransformer. It also outperformed 19 other methods in classification.
  • Prompting is Powerful: One of the most surprising findings is that you can keep the UniTS model weights frozen and only train the "Prompt Tokens" (a process called UniTS-PMT). This prompt-tuned version often performed as well as, or better than, fully fine-tuned specialized models.
  • Efficiency Matters: UniTS is roughly 48x smaller (3.4M parameters) than LLM-based competitors like GPT4TS (164.5M parameters), yet it achieves superior accuracy. Because UniTS can generate any number of tokens, it supports direct multi-step forecasting, making it 3x faster than traditional sliding-window models.
  • Few-Shot Learning: When given only 5% or 10% of a new dataset, UniTS showed a massive advantage, improving imputation MSE by 12.4% over the next best baseline.

Limitations and Future Work

While UniTS is a massive step forward, the authors note a few areas for growth. The current training set doesn't cover every possible niche, such as certain univariate datasets or highly specific physiologic signals. Furthermore, while few-shot performance is excellent, "zero-shot" generalization (performing a task on a totally unseen domain with no training) remains an open challenge. Finally, the researchers plan to experiment with newer architectures like Mamba (State Space Models) to see if they can further improve efficiency for extremely long sequences.

Code and datasets are available at https://github.com/mims-harvard/UniTS.

Summary updated

BibTeX
@inproceedings{gao2024units,
  author = {Shanghua Gao and Teddy Koker and Owen Queen and Thomas Hartvigsen and Theodoros Tsiligkaridis and Marinka Zitnik},
  title = {{UniTS: A Unified Multi-Task Time Series Model}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=nBOdYBptWW},
}
Figure