AdaBERT: Task-Adaptive BERT Compression with Differentiable Neural Architecture Search

Daoyuan Chen, Yaliang Li, Minghui Qiu, Zhen Wang, Bofang Li, Bolin Ding, Hongbo Deng, Jun Huang, Wei Lin, Jingren Zhou

Abstract

Large-scale pre-trained language models like BERT have set new benchmarks in NLP but remain computationally prohibitive for edge deployment. AdaBERT addresses this by introducing a task-adaptive compression framework using Differentiable Neural Architecture Search (NAS). By automatically identifying efficient, task-specific CNN-based architectures and utilizing hierarchical knowledge distillation, AdaBERT produces models that are up to 29x faster and 17x smaller than BERT-base while maintaining competitive performance on the GLUE benchmark.

Introduction

The deployment of models like BERT (110M+ parameters) on mobile and edge devices is limited by high latency and memory requirements. While general-purpose compression methods like DistilBERT provide smaller Transformer-based alternatives, they often overlook the fact that different NLP tasks—such as sentiment analysis versus natural language inference—may not require the same architectural complexity. AdaBERT proposes a shift from "one-size-fits-all" compression to task-adaptive "tiny" models tailored for specific downstream applications.

Methodology: The AdaBERT Framework

AdaBERT combines Neural Architecture Search with Knowledge Distillation (KD) to find the optimal balance between efficiency and accuracy for a given task.

Differentiable Search Space

Instead of searching for heavy Transformer blocks, AdaBERT explores a space of lightweight 1D CNN operations, including standard and dilated convolutions and pooling. To make the discrete selection of operations end-to-end trainable, the framework employs the Gumbel-Softmax trick, allowing the architecture parameters to be optimized via gradient descent alongside model weights.

The AdaBERT framework: Differentiable searching integrates teacher knowledge and model efficiency into the architecture optimization process.

Task-Oriented Knowledge Distillation

A fine-tuned BERT model serves as the teacher. To facilitate knowledge transfer, "probe models" are inserted into the teacher's layers to extract hierarchical features. The student model is trained to mimic these probes. An attention mechanism, termed Attentive Hierarchical Transfer, automatically weighs the importance of different teacher layers based on their relevance to the target task. The optimization process is further guided by an efficiency-aware loss function that penalizes high parameter counts and FLOPs.

Experimental Results

The framework was evaluated on the GLUE benchmark, covering tasks like SST-2 (Sentiment), MRPC (Equivalence), and QNLI (Entailment).

Efficiency and Performance

AdaBERT achieves significant gains in efficiency over the BERT-base baseline:

  • Inference Speed: 12.7x to 29.3x faster than BERT-base.
  • Model Size: 11.5x to 17.0x reduction in parameters (down to ~6.4M–9.5M).
  • Accuracy: Average GLUE score of 80.1, which is remarkably close to the 80.6 achieved by TinyBERT, despite AdaBERT being significantly faster and smaller.

Task-Specific Architectures

A key finding is that the optimal architecture varies significantly by task. Cross-task validation tests showed that an architecture optimized for one task performed poorly on another, confirming that the NAS process captures task-specific structural advantages. For instance, sentiment analysis (SST-2) favors pooling operations for global aggregation, whereas entailment tasks require more complex interactions between text pairs.

Comparison of task-specific architectures searched by AdaBERT for SST-2, MRPC, and QNLI.

Conclusion

AdaBERT demonstrates that task-adaptive compression via NAS can effectively bridge the gap between heavy pre-trained models and resource-constrained deployment environments. By replacing global self-attention with task-specific CNN structures, it achieves state-of-the-art trade-offs in speed, size, and performance. While the search cost remains a consideration, the resulting models offer a viable path for real-time NLP on the edge.

Summary updated

BibTeX
@inproceedings{chen2020adabert,
  author = {Daoyuan Chen and Yaliang Li and Minghui Qiu and Zhen Wang and Bofang Li and Bolin Ding and Hongbo Deng and Jun Huang and Wei Lin and Jingren Zhou},
  title = {{AdaBERT: Task-Adaptive BERT Compression with Differentiable Neural Architecture Search}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2020},
  doi = {10.24963/ijcai.2020/341},
}
Figure