DARTFormer: Finding The Best Type Of Attention

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

Abstract

Given the wide and ever growing range of different efficient Transformer attention mechanisms, it is important to identify which attention is most effective when given a task. In this work, we are also interested in combining different attention types to build heterogeneous Transformers. We first propose a DARTS-like Neural Architecture Search (NAS) method to find the best attention for a given task, in this setup, all heads use the same attention (homogeneous models). Our results suggest that NAS is highly effective on this task, and it identifies the best attention mechanisms for IMDb byte level text classification and Listops. We then extend our framework to search for and build Transformers with multiple different attention types, and call them heterogeneous Transformers. We show that whilst these heterogeneous Transformers are better than the average homogeneous models, they cannot outperform the best. We explore the reasons why heterogeneous attention makes sense, and why it ultimately fails.

Introduction

Since the birth of the Transformer, researchers have developed a "zoo" of efficient attention mechanisms—such as Performer, Reformer, and Linear Transformer—to solve the quadratic scaling bottleneck of the original dot-product attention. However, there is no "one size fits all" solution; an architecture that excels at document matching might fail at logical reasoning tasks like Listops. Currently, researchers typically select an attention type based on intuition or exhaustive trial and error. This paper introduces DARTFormer, a Neural Architecture Search (NAS) framework designed to automatically identify the most effective attention mechanism for a specific task.

Methodology: DARTFormer

The authors propose a method inspired by Differentiable Architecture Search (DARTS) to navigate the vast space of efficient attention mechanisms.

The Supernetwork

The core of DARTFormer is a "supernetwork" where multiple candidate attention blocks run in parallel within a single layer. This structure allows the model to evaluate the relative importance of different attention types simultaneously during the search phase.

The DARTFormer supernetwork architecture, featuring multiple candidate attention mechanisms running in parallel.

Selection via Masked Validation Accuracy Drop

Unlike standard DARTS, which uses learnable weights to choose paths, DARTFormer employs a masked validation accuracy drop metric. After training the supernetwork, individual attention blocks are "masked out" one by one. The block whose absence causes the largest drop in accuracy is deemed the most critical for the task.

Search Paradigms

The framework explores two distinct paradigms:

  1. Homogeneous: Identifying a single best attention type to be used across all heads and layers of the model.
  2. Heterogeneous: Creating a model where different heads or layers utilize different attention types. This is achieved through "NAS Prune," iteratively removing the least effective blocks.
A heterogeneous Transformer layer where different attention mechanisms (e.g., Performer and Reformer) operate in parallel.

Experimental Setup and Datasets

Evaluation was conducted on the Long Range Arena (LRA) benchmark, focusing on long-sequence tasks including IMDb Byte-level text classification (1k length), Listops (2k length), and Document Matching (4k length). The search space included nine popular mechanisms: Bigbird, Linear Transformer, Linformer, Local, Longformer, Performer, Reformer, Sparse Transformer, and Synthesizer.

Key Results and the Heterogeneity Paradox

DARTFormer successfully identified top-performing homogeneous models. For IMDb, it correctly selected the Performer (64.5% accuracy), and for Listops, it identified the Reformer (37.8%) as the winner.

However, the study revealed a surprising "Heterogeneity Paradox." While the authors hypothesized that mixing attention types would provide diverse functional biases—similar to how different kernels benefit Convolutional Neural Networks—heterogeneous models consistently failed to outperform the best homogeneous models. For instance, on the IMDb task, the best heterogeneous mix reached 64.4%, slightly trailing the pure Performer model.

Discussion: Why Heterogeneity Fails

The authors suggest several reasons for this counter-intuitive result:

  • Noise Interference: Poorly suited attention types may introduce noise that degrades overall performance rather than complementing it.
  • Architectural Conflict: Components like Feed-Forward Networks (FFNs) may struggle to process and aggregate conflicting signals from diverse attention mechanisms simultaneously.
  • Task Specificity: Most tasks may only require a single type of relational learning, rendering a "jack of all trades" approach unnecessary.

Conclusion

DARTFormer demonstrates that NAS is a viable shortcut for selecting task-specific attention mechanisms. While heterogeneity did not yield the expected gains, this finding highlights the importance of architectural synergy. Future research may explore co-searching for FFN architectures better suited to aggregating diverse attention outputs or expanding the search space to entirely new attention formulations.

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},
}
Figure