DARTFormer: Finding The Best Type Of Attention

Jason Ross Brown, Yiren Zhao, Ilia Shumailov, Robert D. Mullins

TL;DR

This paper introduces DARTFormer, a Neural Architecture Search (NAS) method to automatically discover the most effective attention mechanism for a given task. While their approach successfully identifies optimal homogeneous attention configurations, it finds that heterogeneous Transformers (combining multiple attention types) do not outperform the best single-type homogeneous models, offering insights into why this might be the case.

What Problem Does This Paper Address?

The Transformer architecture, a cornerstone of modern NLP, relies heavily on the attention mechanism. However, the original dot-product attention has quadratic complexity, leading to the development of numerous efficient attention variants. The challenge is that these efficient attentions often perform best on different tasks, making it unclear which one to choose for a new problem without extensive experimentation. This paper tackles this by asking: can we efficiently learn the best attention mechanism for a given task, and can combining different attention types lead to even better performance?

Methods

The core of this work is DARTFormer, a DARTS-like Neural Architecture Search (NAS) framework. Instead of searching for network architectures, DARTFormer searches for the optimal attention mechanism.

Here's how it works:

  • Supernetwork: They construct a "supernetwork" that encompasses multiple attention types. This supernetwork is trained to convergence.
  • Homogeneous Search: In the first phase, they search for the best single attention mechanism to be used across all heads in a Transformer layer (homogeneous models). This is done by training a single-layer supernetwork where each attention head can be one of the candidate types. They then evaluate each attention type by masking it out and measuring the drop in validation accuracy. The attention type causing the largest drop is considered the best.
  • Heterogeneous Search: In the second phase, they extend the framework to search for optimal combinations of attention types for a Transformer layer (heterogeneous models). This involves a pruning-based NAS approach where they start with multiple attention blocks (each potentially a different type) and iteratively remove the worst-performing ones until only the desired number of heads remain. They also explore a simpler "NAS One-shot" method where they simply pick the top-scoring attentions from the homogeneous search.
  • Evaluation Metric: They use "masked validation accuracy drop" as their primary metric. This involves masking out a specific attention block and observing how much the model's performance degrades. A larger drop indicates a more crucial attention mechanism.

Datasets

The paper evaluates their methods on three tasks from the Long Range Arena (LRA) benchmark:

  • IMDb byte level text classification: 1k sequence length.
  • Listops: 10-way classification with 2k sequence length.
  • Document matching: byte level, 4k sequence length.

Key Insights and Ideas

  • NAS is effective for finding optimal attention: The DARTFormer approach successfully identifies attention mechanisms that perform well on specific tasks, validating the NAS strategy for this problem.
  • Homogeneous attention reigns supreme: Despite the intuition that combining different attention types (heterogeneous models) would be beneficial, the paper's experiments show that the best single attention mechanism (homogeneous model) consistently outperforms any combination.
  • Theories for heterogeneous failure: The authors propose several hypotheses for why heterogeneous attention doesn't yield superior results:
  • Limited functional bias: Perhaps the differences in attention types are not as impactful as assumed, or the performance differences are due to other factors.
  • Task-specific needs: Each task might require a very specific, narrow set of learned relationships, making a homogeneous attention tailored to that subset optimal.
  • Degradation from poor choices: Including a few poorly suited attention types in a heterogeneous mix might actively degrade performance.
  • Conflicting learning pressures: Different attention mechanisms might impose conflicting learning objectives on other parts of the Transformer (like the feed-forward network), hindering overall performance.

Key Results

  • Homogeneous models perform well: For IMDb text classification and Listops, their NAS method correctly identified the best-performing homogeneous attention mechanisms. For document matching, the single-layer search was less confident but still provided useful insights.
  • Heterogeneous models are better than average, but not the best: The heterogeneous Transformer models developed through NAS generally performed better than the average homogeneous model but consistently fell short of the best homogeneous model found.
  • NAS Prune vs. NAS One-shot: The more complex "NAS Prune" method did not consistently offer advantages over the simpler "NAS One-shot" approach for finding good heterogeneous combinations.

Limitations and Future Work

  • Heterogeneous limitations: The primary limitation is that heterogeneous Transformers, as explored in this work, do not surpass the best homogeneous models. The paper dedicates a section to exploring theoretical reasons for this.
  • Future work: The authors suggest further comprehensive studies to investigate the effects of combining different attention types and to explore the theories proposed for heterogeneous attention's sub-optimality. They also mention experimenting with head-wise homogeneous, layer-wise heterogeneous attention, which is detailed in Appendix B.

Summary updated

BibTeX
@inproceedings{brown2022dartformer,
  author = {Jason Ross Brown and Yiren Zhao and Ilia Shumailov and Robert D. Mullins},
  title = {{DARTFormer: Finding The Best Type Of Attention}},
  booktitle = {ICBINB @ NeurIPS},
  year = {2022},
  url = {https://openreview.net/forum?id=hFPRLiUORV},
}

Loading related content...

Figure