TinyBERT: Distilling BERT for Natural Language Understanding

Xiaoqi Jiao, Yichun Yin, Lifeng Shang, Xin Jiang, Xiao Chen +3 more
9/23/2019
cs.CLcs.AIcs.LG

Official code: huawei-noah/Pretrained-Language-Model (3,162 stars, last commit 2024-01-22).

Abstract

Language model pre-training, such as BERT, has significantly improved the performances of many natural language processing tasks. However, pre-trained language models are usually computationally expensive, so it is difficult to efficiently execute them on resource-restricted devices. To accelerate inference and reduce model size while maintaining accuracy, we first propose a novel Transformer distillation method that is specially designed for knowledge distillation (KD) of the Transformer-based models. By leveraging this new KD method, the plenty of knowledge encoded in a large teacher BERT can be effectively transferred to a small student Tiny-BERT. Then, we introduce a new two-stage learning framework for TinyBERT, which performs Transformer distillation at both the pretraining and task-specific learning stages. This framework ensures that TinyBERT can capture he general-domain as well as the task-specific knowledge in BERT. TinyBERT with 4 layers is empirically effective and achieves more than 96.8% the performance of its teacher BERTBASE on GLUE benchmark, while being 7.5x smaller and 9.4x faster on inference. TinyBERT with 4 layers is also significantly better than 4-layer state-of-the-art baselines on BERT distillation, with only about 28% parameters and about 31% inference time of them. Moreover, TinyBERT with 6 layers performs on-par with its teacher BERTBASE.

View on arXivView PDF

Code Implementations(1)

Pretrained language model and its related optimization techniques developed by Huawei Noah's Ark Lab.

3,162640C++, ShellDec 2, 20192 years ago
knowledge-distillationlarge-scale-distributedmodel-compressionpretrained-modelsquantization

Similar Papers

Cite this paper

@article{jiao2019tinybert,
  title  = {TinyBERT: Distilling BERT for Natural Language Understanding},
  author = {Xiaoqi Jiao and Yichun Yin and Lifeng Shang and Xin Jiang and Xiao Chen and Linlin Li and Fang Wang and Qun Liu},
  year   = {2019},
  eprint = {1909.10351},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1909.10351}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/1909.10351.svg)](https://codeofpaper.com/paper/1909.10351)

Discussion