Skip to main content
QUICK REVIEW

[Paper Review] Neural Architecture Search on Efficient Transformers and Beyond

Zexiang Liu, Dong Li|arXiv (Cornell University)|Jul 28, 2022
Advanced Neural Network ApplicationsComputer Science11 citations
TL;DR

This paper proposes a neural architecture search (NAS) framework to automatically discover optimal architectures for efficient Transformers, specifically targeting the kernel-based cosFormer. By introducing a mixed-attention search space that combines Softmax and linear attention, the method achieves performance comparable to standard Transformers with significantly improved computational efficiency, outperforming purely efficient models in accuracy while maintaining low FLOPS.

ABSTRACT

Recently, numerous efficient Transformers have been proposed to reduce the quadratic computational complexity of standard Transformers caused by the Softmax attention. However, most of them simply swap Softmax with an efficient attention mechanism without considering the customized architectures specially for the efficient attention. In this paper, we argue that the handcrafted vanilla Transformer architectures for Softmax attention may not be suitable for efficient Transformers. To address this issue, we propose a new framework to find optimal architectures for efficient Transformers with the neural architecture search (NAS) technique. The proposed method is validated on popular machine translation and image classification tasks. We observe that the optimal architecture of the efficient Transformer has the reduced computation compared with that of the standard Transformer, but the general accuracy is less comparable. It indicates that the Softmax attention and efficient attention have their own distinctions but neither of them can simultaneously balance the accuracy and efficiency well. This motivates us to mix the two types of attention to reduce the performance imbalance. Besides the search spaces that commonly used in existing NAS Transformer approaches, we propose a new search space that allows the NAS algorithm to automatically search the attention variants along with architectures. Extensive experiments on WMT' 14 En-De and CIFAR-10 demonstrate that our searched architecture maintains comparable accuracy to the standard Transformer with notably improved computational efficiency.

Motivation & Objective

  • To address the suboptimal performance of handcrafted architectures in efficient Transformers, which are often adapted from standard Transformer designs.
  • To investigate whether NAS can discover customized architectures specifically tailored for efficient attention mechanisms like linear attention.
  • To explore the trade-off between accuracy and efficiency in efficient Transformers, particularly when replacing Softmax attention with linear alternatives.
  • To propose and validate a novel mixed-attention mechanism that combines Softmax and linear attention within a single model to balance performance and efficiency.
  • To demonstrate the effectiveness of the proposed NAS framework on real-world tasks such as machine translation and image classification.

Proposed method

  • Adopt the RankNAS framework to accelerate neural architecture search by using pairwise ranking and hardware-aware constraints, reducing search cost.
  • Design a new search space that allows the NAS algorithm to jointly search for both architectural hyperparameters (e.g., head count, feed-forward dimension) and attention type (Softmax vs. linear) per layer.
  • Use the cosFormer as the target efficient Transformer model, replacing its Softmax attention with linear attention to enable efficient computation with O(N) complexity.
  • Perform NAS on two benchmark tasks: WMT’14 En-De machine translation and CIFAR-10 image classification to evaluate generalization.
  • Introduce the mFormer architecture, which dynamically selects between Softmax and linear attention per layer based on search results, enabling hybrid attention mechanisms.
  • Apply search space pruning and early stopping to improve efficiency during the NAS process without sacrificing model quality.

Experimental results

Research questions

  • RQ1Can neural architecture search discover architectures that are more suitable for efficient Transformers than handcrafted designs originally built for standard Transformers?
  • RQ2How does the performance of purely efficient Transformers (e.g., cosFormer) compare to standard Transformers in terms of accuracy and FLOPS when using the same search space?
  • RQ3Does a mixed-attention mechanism—combining Softmax and linear attention—lead to better balance between accuracy and computational efficiency than using either type exclusively?
  • RQ4What architectural patterns emerge in the optimal models discovered by NAS for efficient Transformers across different tasks?
  • RQ5Can the proposed NAS framework achieve high accuracy with significantly reduced FLOPS compared to standard Transformers while maintaining competitive performance?

Key findings

  • The optimal architecture for the efficient cosFormer model has 18% fewer parameters and 18% lower FLOPS than the standard Transformer, but with lower accuracy, indicating a performance-efficiency imbalance.
  • The mFormer model, which uses a mix of Softmax and linear attention, achieves comparable BLEU score to the standard Transformer (1.51 points lower) while reducing FLOPS by 23% and parameters by 20%.
  • On CIFAR-10, the mFormer outperforms the cosFormer* by 5.19 percentage points in accuracy while increasing FLOPS by only 1.38G, demonstrating superior balance.
  • Replacing all linear attention in the mFormer with Softmax leads to a slight accuracy gain but a significant increase in FLOPS, confirming the efficiency-cost trade-off.
  • Replacing all Softmax attention in the Transformer* with linear attention causes a large drop in accuracy (especially on image classification), showing the limitations of linear attention in accuracy-sensitive tasks.
  • The mFormer architecture features a 'shallow and thin' design with mixed attention: 25% of layers use linear attention (e.g., Layer 3, 7, 11), while the rest use Softmax, with head count inversely correlated to feed-forward dimension.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.