TEST: Text Prototype Aligned Embedding to Activate LLM's Ability for Time Series

Chenxi Sun, Hongyan Li, Yaliang Li, Shenda Hong

Large Language Models (LLMs) have revolutionized natural language processing and computer vision, but their application to Time-Series (TS) data—such as medical vitals, stock prices, or weather patterns—has lagged. Time-series data is abstract, lacks the semantic richness of human language, and is often multivariate, making it difficult for models trained on text to natively "understand."

Current approaches to this problem typically fall into two camps:

  1. LLM-for-TS (Model-centric): Designing and training a new foundation model from scratch or fine-tuning an existing LLM on TS data. This is computationally expensive and can cause the LLM to lose its original language capabilities.
  2. TS-for-LLM (Data-centric): Converting TS data into a format the LLM can process. However, simply feeding raw numbers into an LLM as text is inaccurate and fails to capture complex temporal dependencies.

To bridge this gap, researchers have introduced TEST (Text Prototype Aligned Embedding), a framework that enables frozen LLMs to perform complex time-series tasks by aligning time-series data with the LLM's native text embedding space. By treating LLMs as "pattern machines," TEST achieves state-of-the-art performance in classification and forecasting without needing to fine-tune the massive underlying language model.

The TEST Methodology

The core idea behind TEST is to map time-series data into the same high-dimensional space that the LLM uses for words, effectively creating a "model-friendly" representation that activates the LLM's inherent pattern recognition abilities. The process involves several key steps:

  1. Tokenization & Encoding: Time series are segmented into subsequences (tokens). A causal Temporal Convolutional Network (TCN) acts as an encoder to transform these segments into initial embeddings.
  2. Contrastive Learning with Text Prototypes: Instead of just learning to distinguish between different TS samples, TEST aligns TS embeddings with text prototypes—representative embeddings from the LLM's own vocabulary (e.g., words like "up," "down," or "stable"). This forces the TS embeddings into a space the LLM already understands.
  3. Soft Prompting: The framework uses learnable "soft prompts" to instruct the frozen LLM on the specific task (classification or forecasting) without changing the LLM's weights.
  4. Frozen LLM as a Pattern Machine: The aligned TS embeddings and soft prompts are fed into a frozen LLM. The LLM processes these as a sequence of patterns, and a small task-specific head (classifier or regressor) produces the final output.
The TEST framework encodes time-series data, aligns it with text prototypes, and feeds it into a frozen LLM alongside learnable soft prompts.

Key Insights and Performance

The researchers evaluated TEST across multiple tasks, including classification (128 univariate datasets from the UCR archive and 30 multivariate datasets from the UEA archive), forecasting (ETT, Weather, Illness, Electricity, and Traffic), and zero-shot learning (M4, M3, TOURISM, and ELECTR).

TEST was evaluated using eight different LLMs, including GPT-2, BERT, ChatGLM, and LLaMA-2. The results highlight several critical insights:

  • LLMs as Pattern Machines: The paper reinforces the idea that LLMs are powerful general-purpose pattern recognizers. By aligning TS data to their embedding space, we can tap into this latent power without retraining.
  • The Power of Alignment: Aligning TS embeddings to text prototypes is significantly more effective than direct numerical input. Interestingly, the authors found that the number of prototypes matters more than their specific semantic meaning, likely due to the high-dimensionality and near-orthogonality of vectors in the LLM's embedding space.
  • State-of-the-Art Performance: TEST-enabled LLMs achieved performance comparable to or better than specialized state-of-the-art time-series models like TimesNet and DLinear.
  • Scaling Laws: Performance improves as the LLM size increases. Models with ~300M parameters (like GPT2-Medium) began to consistently outperform traditional baselines.
UCR classification accuracy improves as LLM size and prompt length increase, with TEST-enabled models reaching state-of-the-art levels.

Furthermore, TEST showed remarkable gains in few-shot forecasting, achieving a 23.5% relative average MSE reduction compared to baselines. In zero-shot settings, it outperformed almost all recent state-of-the-art methods. The authors also provided a theoretical proof showing that soft prompt tuning is approximately equivalent to supervised fine-tuning when the TS and word embeddings are properly aligned.

Limitations and Future Directions

While TEST is a powerful step forward, the authors note a few areas for improvement. The external encoder's robustness can sometimes be a weak point compared to end-to-end trained models. Additionally, while TEST aligns data at a machine level, aligning objective TS data with subjective human text descriptions (e.g., "this looks like a sepsis pattern") remains a challenge. Future work will look deeper into the correlations between massive text corpora and time-series patterns to further improve pre-training strategies.

Summary updated

BibTeX
@inproceedings{sun2024test,
  author = {Chenxi Sun and Hongyan Li and Yaliang Li and Shenda Hong},
  title = {{TEST: Text Prototype Aligned Embedding to Activate LLM's Ability for Time Series}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=Tuh4nZVb0g},
}
Figure