DARKER: Efficient Transformer with Data-driven Attention Mechanism for Time Series

Rundong Zuo, Guozhong Li, Rui Cao, Byron Choi, Jianliang Xu, Sourav S. BhowmickPVLDB 2024 · DOI

TL;DR

This paper introduces DARKER, a novel transformer architecture that significantly speeds up time series analysis by employing a data-driven attention mechanism. By learning multiple attention projections tailored to the data, DARKER achieves linear time complexity, making it much more efficient than previous transformer models for long time series.

What Problem Does This Paper Address?

Transformers have revolutionized many fields, including time series analysis, due to their powerful attention mechanisms. However, the standard self-attention mechanism in transformers has a quadratic time complexity with respect to the input sequence length. This quadratic dependency becomes a major bottleneck when dealing with long time series, making training prohibitively slow and computationally expensive. While some efficient transformer variants exist, they often rely on fixed, data-agnostic approximations or require specific data priors that limit their applicability. This paper addresses the need for an efficient transformer that can handle long time series without sacrificing accuracy and without requiring restrictive assumptions about the data.

Methods

The core innovation of DARKER is its DAta-dRiven KERnel-based attention mechanism. Instead of using a single, fixed projection to approximate the softmax kernel in attention (as in Random Feature Attention methods), DARKER learns multiple, data-specific projections.

Here's a breakdown of the key techniques:

  • Data-Driven Projections: DARKER trains small machine learning models (MLPs) on individual time series instances to learn projections that approximate the softmax kernel. This allows the attention mechanism to adapt to the specific data distribution, unlike fixed RFA methods.
  • PINDEX (Projection Index): To efficiently retrieve the learned projections for new or unseen time series, DARKER introduces PINDEX. This indexing mechanism uses clustering and Hamming distance on shape representations to quickly find the most suitable learned projection, avoiding the need to re-train for every new instance.
  • Optimized Shape Discovery: The paper also proposes an efficient method for discovering "shapes" (discriminative time series subsequences) from raw time series data. This involves clustering subsequences and using an index (Ic2d) to efficiently map them to cluster centers, which are then used for representation in PINDEX.
  • Linear Time Complexity: By learning and indexing these data-driven projections, DARKER reduces the attention mechanism's time complexity from quadratic O(N²) to linear O(N), where N is the input sequence length.

Datasets

The authors evaluated DARKER on a comprehensive set of datasets:

  • 14 real-world time series datasets from the UEA archive.
  • 2 synthetic time series datasets designed for larger-scale evaluation.

No new benchmarks were introduced; the focus was on evaluating performance on existing, well-established time series classification datasets.

Key Insights and Ideas

  • Data-Driven Attention is Crucial for Time Series: The paper strongly argues that fixed, data-agnostic attention approximations (like standard RFA) are insufficient for time series due to their inherent variability. Learning projections tailored to the data distribution is key to both efficiency and accuracy.
  • PINDEX Significantly Boosts Efficiency: The introduction of PINDEX is a critical component for practical deployment. It allows for rapid retrieval of learned projections, making the overall process efficient even for unseen data, outperforming Euclidean distance-based ANN search by at least 20x.
  • Shape Discovery Matters, but Efficiency is Key: While discriminative shapes are important for time series tasks, the process of discovering them can be a bottleneck. DARKER's optimized shape discovery, coupled with PINDEX, addresses this by making the entire pipeline efficient.
  • RFA Methods Suffer from Overflow and Approximation Errors: The paper highlights practical issues with existing RFA methods, such as numerical overflow and higher approximation errors, which can lead to unstable accuracy, especially on datasets with high variance. DARKER effectively mitigates these problems.

Key Results

  • Efficiency: DARKER is significantly faster than vanilla transformers and other state-of-the-art (SOTA) efficient methods. It achieves a 3x-4x speedup over vanilla transformers and 1.5x-3x speedup over other SOTAs for long sequences. The training time scales modestly with sequence length, unlike the dramatic increase seen in vanilla transformers.
  • Accuracy: DARKER achieves accuracy comparable to or higher than all compared transformers. It often trails closely behind the full attention mechanism and shows competitive performance against other SOTA methods.
  • Reduced FLOPs: DARKER reduces FLOPs by over 30x compared to full attention and 18x compared to RFA methods, demonstrating its computational efficiency.
  • Lower Approximation Error: The paper shows that DARKER has lower and more stable approximation errors compared to RFA-pos, indicating a better approximation of the softmax kernel.

Limitations and Future Work

  • Limitations:
    • The paper notes that while DARKER's accuracy is comparable to SOTA, it might slightly trail behind full attention in some cases.
  • The effectiveness of PINDEX relies on the quality of shape discovery and clustering.
  • The paper mentions that the performance can be enhanced by increasing the size of the initial shape set ($S_0$), which implies a trade-off between efficiency and accuracy.
  • Future Work:
    • The authors plan to apply DARKER to other downstream time series tasks, such as time series clustering.
  • They also aim to reduce the I/O time in GPU processing.

Summary updated

BibTeX
@article{zuo2024darker,
  author = {Rundong Zuo and Guozhong Li and Rui Cao and Byron Choi and Jianliang Xu and Sourav S. Bhowmick},
  title = {{DARKER: Efficient Transformer with Data-driven Attention Mechanism for Time Series}},
  journal = {Proc. VLDB Endow.},
  year = {2024},
  doi = {10.14778/3681954.3681996},
}
Figure