Text2Freq: Learning Series Patterns from Text via Frequency Domain

Ming-Chih Lo, Ching Chang, Wen-Chih Peng

TL;DR

This paper introduces Text2Freq, a novel method for time series forecasting that bridges the gap between textual information and numerical data by leveraging the frequency domain. By aligning text to the low-frequency components of time series, Text2Freq achieves state-of-the-art performance, offering a more interpretable and effective way to incorporate external textual insights into forecasting.

What Problem Does This Paper Address?

Traditional time series forecasting models primarily rely on historical numerical data. While effective, they often miss crucial context provided by external factors like news events or market sentiment, which are typically captured in text. Integrating text with time series data is challenging due to a significant "modality gap": text is discrete and rich in semantics, while time series are continuous and focus on temporal changes. Furthermore, text often describes high-level trends, leading to a "one-to-many" mapping problem where a single text description could correspond to multiple time series patterns. This paper aims to overcome these challenges by developing a method that effectively aligns textual information with time series data for improved forecasting.

Methods

The proposed Text2Freq model operates in two stages:

  1. Pre-trained Text-to-Frequency Transformer: This stage focuses on learning how to represent textual information in a way that's compatible with time series data.
  2. Text Encoding: A pre-trained BERT model is used to extract rich semantic embeddings from text.
  3. Frequency Domain Alignment: These text embeddings are then mapped to the latent space of low-frequency components of time series data using a Transformer Encoder. This is a key innovation, as it focuses on the more stable, trend-like aspects of the time series.
  4. Variational Autoencoder (VAE): A VAE is employed to enhance the latent space representation in the frequency domain, inspired by prior work on vector-quantized time series generation.
  5. Pre-training Dataset: To mitigate the scarcity of paired text-time series data, this stage is pre-trained on the TRUCE dataset, which contains a larger collection of weekly stock prices and associated text.
  6. Multimodal Fusion: In this stage, the pre-trained text-to-frequency module is frozen, and the model learns to combine the processed text information with the original time series data.
  7. Unimodal Forecasting: A separate model (PatchTST is used as a baseline) forecasts the time series using only historical numerical data.
  8. Fusion Layer: The outputs from the text-to-frequency module and the unimodal time series forecasting model are concatenated and then processed through an attention mechanism. This allows the model to effectively learn from and integrate information from both modalities to generate the final prediction.

A novel aspect of Text2Freq is its explicit focus on aligning text with the low-frequency components of the time series, aiming to capture global trends and avoid noise or spurious correlations.

Datasets

  • TRUCE Dataset: Used for pre-training the Text-to-Frequency Transformer. It contains weekly stock prices from seven companies over a significant period, with paired text data.
  • Stock Price Dataset (AAPL, MSFT, GOOG): Used for evaluating the Text2Freq model. This dataset consists of weekly stock prices from December 1, 2006, to November 30, 2016.
  • Synthetic Text Generation: To address the limited availability of real-world paired data for the main evaluation, GPT-4 was used to generate synthetic "ground-truth" descriptions of future patterns for the stock price data. This synthetic data was used as the textual input for the evaluation stage.

Key Insights and Ideas

  • Frequency Domain as a Bridge: Mapping text to the frequency domain, specifically to low-frequency components, proves to be a more effective way to bridge the modality gap between text and time series than direct text-to-series mapping. This is because low-frequency components capture stable trends, which are more likely to be represented by high-level textual descriptions.
  • Optimal Subset of Frequencies: Simply using all frequency components can lead to one-to-many mapping issues (too much detail, noise), while using only the very lowest frequency can lead to many-to-one issues (losing too much information). The paper suggests that an "optimal subset" of low-frequency components balances information and noise.
  • Textual Information Enhances Forecasting: Incorporating textual information, even synthetic, significantly improves forecasting performance compared to unimodal models. This highlights the value of external context.
  • Interpretability: Aligning text to specific frequency components offers a more interpretable way to understand how textual information influences forecasting, as opposed to black-box cross-attention mechanisms.

Key Results

  • Performance Improvement: Text2Freq achieved a 14% improvement in Mean Squared Error (MSE) compared to an attention-based multimodal baseline.
  • Alignment Strategy: Mapping text to the frequency domain (specifically, to a subset of low-frequency components) outperformed direct text-to-series mapping by over 6% in MSE.
  • Baseline Comparison: Text2Freq and the attention-based multimodal model significantly reduced MSE (26% and 14% respectively) compared to the unimodal PatchTST model.
  • Quantitative Results: Table 1 shows Text2Freq outperforming both Attention Fusion and PatchTST across MSFT, AAPL, and GOOG stocks in terms of MSE and MAE. Table 2 demonstrates the superiority of frequency domain mapping over direct text-series mapping.

Limitations and Future Work

  • Dataset Limitation (Information Leakage): The authors acknowledge a limitation in their evaluation dataset where the text input for stage 2 was based on "ground truth descriptions of future patterns" due to limited available real-world paired data. This means the text might have contained information that would not be available in a true forecasting scenario.
  • Future Work - Real-World Data: Future research will focus on evaluating Text2Freq with real-world textual data sources, such as news articles or event descriptions, to ensure more robust validation.
  • Future Work - Advanced Models: The authors suggest integrating their pre-trained framework with advanced models from time series forecasting and natural language processing, including foundation models, to further enhance performance and interpretability.
  • Future Work - Diverse Modalities: Exploring the integration of other data modalities alongside text and time series is also a promising direction.

Summary updated

BibTeX
@inproceedings{lo2024text,
  author = {Ming-Chih Lo and Ching Chang and Wen-Chih Peng},
  title = {{Text2Freq: Learning Series Patterns from Text via Frequency Domain}},
  booktitle = {TSALM @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=Pi6sA1MSSr},
}
Figure