SmartBERT: A Promotion of Dynamic Early Exiting Mechanism for Accelerating BERT Inference

4Citations
Citations of this article
10Readers
Mendeley users who have this article in their library.

Abstract

Dynamic early exiting has been proven to improve the inference speed of the pre-trained language model like BERT. However, all samples must go through all consecutive layers before early exiting and more complex samples usually go through more layers, which still exists redundant computation. In this paper, we propose a novel dynamic early exiting combined with layer skipping for BERT inference named SmartBERT, which adds a skipping gate and an exiting operator into each layer of BERT. SmartBERT can adaptively skip some layers and adaptively choose whether to exit. Besides, we propose cross-layer contrastive learning and combine it into our training phases to boost the intermediate layers and classifiers which would be beneficial for early exiting. To keep the consistent usage of skipping gates between training and inference phases, we propose a hard weight mechanism during training phase. We conduct experiments on eight classification datasets of the GLUE benchmark. Experimental results show that SmartBERT achieves 2-3× computation reduction with minimal accuracy drops compared with BERT and our method outperforms previous methods in both efficiency and accuracy. Moreover, in some complex datasets like RTE and WNLI, we prove that the early exiting based on entropy hardly works, and the skipping mechanism is essential for reducing computation. Our codes are available at: https://github.com/HuBoren99/SmartBert.

Cite

CITATION STYLE

APA

Hu, B., Zhu, Y., Li, J., & Tang, S. (2023). SmartBERT: A Promotion of Dynamic Early Exiting Mechanism for Accelerating BERT Inference. In IJCAI International Joint Conference on Artificial Intelligence (Vol. 2023-August, pp. 5067–5075). International Joint Conferences on Artificial Intelligence. https://doi.org/10.24963/ijcai.2023/563

Register to see more suggestions

Mendeley helps you to discover research relevant for your work.

Already have an account?

Save time finding and organizing research with Mendeley

Sign up for free