Skip to main content
QUICK REVIEW

[Paper Review] MobileBERT: a Compact Task-Agnostic BERT for Resource-Limited Devices

Zhiqing Sun, Hongkun Yu|arXiv (Cornell University)|Apr 6, 2020
Topic ModelingComputer Science50 references90 citations
TL;DR

MobileBERT is a task-agnostic, compact variant of BERT designed for mobile devices; it is 4.3x smaller and 5.5x faster than BERT-BASE while remaining competitive on GLUE and SQuAD benchmarks.

ABSTRACT

Natural Language Processing (NLP) has recently achieved great success by using huge pre-trained models with hundreds of millions of parameters. However, these models suffer from heavy model sizes and high latency such that they cannot be deployed to resource-limited mobile devices. In this paper, we propose MobileBERT for compressing and accelerating the popular BERT model. Like the original BERT, MobileBERT is task-agnostic, that is, it can be generically applied to various downstream NLP tasks via simple fine-tuning. Basically, MobileBERT is a thin version of BERT_LARGE, while equipped with bottleneck structures and a carefully designed balance between self-attentions and feed-forward networks. To train MobileBERT, we first train a specially designed teacher model, an inverted-bottleneck incorporated BERT_LARGE model. Then, we conduct knowledge transfer from this teacher to MobileBERT. Empirical studies show that MobileBERT is 4.3x smaller and 5.5x faster than BERT_BASE while achieving competitive results on well-known benchmarks. On the natural language inference tasks of GLUE, MobileBERT achieves a GLUEscore o 77.7 (0.6 lower than BERT_BASE), and 62 ms latency on a Pixel 4 phone. On the SQuAD v1.1/v2.0 question answering task, MobileBERT achieves a dev F1 score of 90.0/79.2 (1.5/2.1 higher than BERT_BASE).

Motivation & Objective

  • Motivate and enable deployment of BERT-like models on resource-limited devices.
  • Design a deep, narrow Transformer variant that preserves performance through bottleneck structures.
  • Develop teacher-student knowledge transfer to train a thin MobileBERT from an inverted-bottleneck teacher.
  • Optimize operational aspects to reduce mobile inference latency.
  • Demonstrate task-agnostic fine-tuning capability across standard NLP benchmarks.

Proposed method

  • Introduce bottleneck and inverted-bottleneck blocks to keep depth while narrowing width.
  • Use 4 stacked FFNs per layer to rebalance MHA and FFN parameter distribution.
  • Train a deep teacher IB-BERT-LARGE with 512 feature maps and distill to MobileBERT layer-wise.
  • Apply feature map transfer and attention transfer as layer-wise knowledge transfer objectives.
  • Incorporate pre-training distillation combining MLM, NSP, and KD losses.
  • Explore training strategies: Auxiliary, Joint, and Progressive Knowledge Transfer; progressively train layers with optional fine-tuning of lower layers.
  • Embed factorization: reduce embedding dimension to 128 and apply a 1D convolution to recover 512-dim outputs.
  • Operational optimizations: replace LayerNorm with NoNorm and gelu with ReLU to reduce latency.

Experimental results

Research questions

  • RQ1Can a deep, narrow BERT-like model retain competitive performance across standard NLP benchmarks when trained via layer-wise knowledge transfer from a teacher with inverted bottlenecks?
  • RQ2What training strategies and architectural choices best balance accuracy, model size, and mobile latency for a task-agnostic compressed BERT?
  • RQ3How do embedding factorization and operational optimizations affect accuracy and real-world latency on mobile devices?
  • RQ4To what extent can MobileBERT approach BERT-BASE performance on GLUE and SQuAD while offering substantial speedups?

Key findings

  • MobileBERT achieves 4.3x model size reduction and 5.5x faster inference than BERT-BASE.
  • On GLUE, MobileBERT attains a GLUE score of 77.7, only 0.6 points below BERT-BASE, with 62 ms latency on a Pixel 4.
  • On SQuAD v1.1/v2.0, MobileBERT achieves dev F1 scores of 90.0/79.2, outperforming BERT-BASE by 1.5/2.1 points in v1.1/v2.0 respectively.
  • MobileBERT-TINY and quantized variants further reduce size with minimal or no loss in accuracy, and post-training quantization yields additional compression with negligible degradation.
  • Operational optimizations (NoNorm and ReLU) significantly reduce real-world latency without reducing FLOPs, highlighting gaps between FLOPs and actual latency.
  • Progressive knowledge transfer consistently outperforms auxiliary or joint strategies, improving GLUE and SQuAD results.

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.