Analyzing Deep Transformer Models for Time Series Forecasting via Manifold Learning

Ilya Kaufman, Omri AzencotSubmission to ICLR 2024 · Rejected

While Transformer models have revolutionized natural language processing and computer vision, their application to Time Series Forecasting (TSF) remains somewhat of a "black box." We know these models achieve state-of-the-art results, but we lack a deep understanding of how they transform raw numerical sequences into accurate future predictions.

Unlike images or text, time series data lacks intuitive "natural" features that are easy for humans to visualize. To bridge this interpretability gap, recent research employs Manifold Learning. This approach relies on the "manifold hypothesis": the idea that high-dimensional data (such as a 512-dimension hidden layer in a neural network) actually resides on a much simpler, low-dimensional geometric surface. By measuring the properties of this surface, researchers can track how a model processes information layer by layer.

Measuring the Manifold: ID and Curvature

To analyze the internal states of state-of-the-art TSF Transformers like Autoformer and FEDformer, researchers utilize two specialized geometric metrics:

  1. Intrinsic Dimension (ID): Estimated using the Two Nearest Neighbors (TwoNN) method, ID reveals the minimum number of variables needed to describe the data without losing information.
  2. Mean Absolute Principal Curvature (MAPC): Calculated via Curvature Aware Manifold Learning (CAML), this metric measures how much the manifold "bends" or deviates from being a perfectly flat plane.

By extracting latent representations from every layer of these models across various large-scale datasets (including ETT, Electricity, Traffic, and Weather), researchers can plot "geometric profiles" that describe the model's internal state throughout the forecasting process.

The Two-Phase Geometric Journey

One of the most striking discoveries is how TSF Transformers process data compared to models in other domains. Image classification models typically show a "hunchback" ID profile, where dimensionality rises and then falls. In contrast, TSF Transformers exhibit a distinct two-phase journey.

Intrinsic Dimension (ID) and Mean Absolute Principal Curvature (MAPC) across layer depth for Autoformer and FEDformer. The vertical line marks the transition from encoder to decoder.

As seen in the geometric profiles, during the encoding phase (layers 1-4), the manifold stays relatively flat or simplifies. However, during the decoding phase (layers 5-7), both dimensionality and curvature experience a sharp spike. This suggests that the decoder actively "expands" the representation to capture the complex variance required for multi-step future prediction.

Curvature as a Predictor of Performance

Perhaps the most actionable insight from this geometric analysis is the relationship between manifold curvature and model accuracy. There is a significant positive correlation between the curvature of the final layer and the model's Mean Squared Error (MSE).

Essentially, flatter manifolds lead to better forecasts. The correlation coefficient between the final layer's MAPC and the test MSE was found to be 0.76 for Autoformer and 0.70 for FEDformer. This is a major breakthrough because it suggests we could potentially evaluate—or even regularize—models based on their internal geometry without needing a holdout test set.

Dataset Fingerprints and Rapid Convergence

The geometric analysis also revealed that models learn these manifolds incredibly fast. The geometric profile of a model stabilizes within just the first five epochs of training. Furthermore, the encoder's geometry converges almost immediately (within 2 epochs), indicating that the "heavy lifting" of learning the specific forecasting task happens primarily in the decoder.

Intrinsic Dimension profiles across layers for different datasets and prediction lengths, revealing distinct geometric 'fingerprints' for each dataset.

Additionally, the data itself leaves a distinct mark on the model's geometry. Related datasets produce remarkably similar geometric manifolds. For example, Traffic and Electricity datasets—both of which feature strong, predictable seasonal patterns—yield similar "fingerprints" across the network layers, whereas unrelated datasets like Weather look structurally different.

Future Directions

While these models operate in an extrinsic dimension of $D=512$, this research proves the data actually lives on a manifold with an ID between just 1.2 and 8.1. However, the relatively flat "slope" of the relationship between curvature and error across different datasets suggests that current architectures might not be expressive enough to fully capture the complexity of datasets with hundreds of features.

Moving forward, these geometric tools open exciting new avenues for TSF research. Future work could involve designing novel loss functions that explicitly penalize high manifold curvature to improve generalization, or using these profiles as a diagnostic tool to compare emerging architectures (like PatchTST) without relying solely on traditional benchmark scores.

Summary updated

Abstract

Deep transformer models consistently achieve groundbreaking results on natural language processing and computer vision problems, among other engineering and scientific domains. However, despite active research that aims to better understand transformer neural networks via e.g., computing saliency scores or analyzing their attention matrix, these models are not well-understood at large. This problem is further exacerbated for deep time series forecasting methods, for which analysis and understanding work is relatively scarce. Indeed, deep time series forecasting methods only recently emerged as state-of-the-art, and moreover, time series data may be less ``natural'' to interpret and analyze, unlike image and text information. Complimentary to existing analysis studies, we employ a manifold learning viewpoint, i.e., we assume that latent representations of time series forecasting models lie next to a low-dimensional manifold. In this work, we study geometric features of latent data manifolds including their intrinsic dimension and principal curvatures. Our results demonstrate that deep transformer models share a similar geometric behavior across layers, and that geometric features are correlated with model performance. Further, untrained models present different structures, which rapidly converge during training. Our geometric analysis and differentiable tools may be used in designing new and improved deep forecasting neural nets.
BibTeX
@misc{kaufman2024analyzing,
  author = {Ilya Kaufman and Omri Azencot},
  title = {{Analyzing Deep Transformer Models for Time Series Forecasting via Manifold Learning}},
  year = {2024},
  eprint = {2410.13792},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.13792},
}
Figure