TR-BERT: Dynamic Token Reduction for Accelerating BERT Inference

Deming Ye, Yankai Lin, Yufei Huang, Maosong Sun


Abstract
Existing pre-trained language models (PLMs) are often computationally expensive in inference, making them impractical in various resource-limited real-world applications. To address this issue, we propose a dynamic token reduction approach to accelerate PLMs’ inference, named TR-BERT, which could flexibly adapt the layer number of each token in inference to avoid redundant calculation. Specially, TR-BERT formulates the token reduction process as a multi-step token selection problem and automatically learns the selection strategy via reinforcement learning. The experimental results on several downstream NLP tasks show that TR-BERT is able to speed up BERT by 2-5 times to satisfy various performance demands. Moreover, TR-BERT can also achieve better performance with less computation in a suite of long-text tasks since its token-level layer number adaption greatly accelerates the self-attention operation in PLMs. The source code and experiment details of this paper can be obtained from https://github.com/thunlp/TR-BERT.
Anthology ID:
2021.naacl-main.463
Volume:
Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies
Month:
June
Year:
2021
Address:
Online
Venue:
NAACL
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
5798–5809
Language:
URL:
https://aclanthology.org/2021.naacl-main.463
DOI:
10.18653/v1/2021.naacl-main.463
Bibkey:
Cite (ACL):
Deming Ye, Yankai Lin, Yufei Huang, and Maosong Sun. 2021. TR-BERT: Dynamic Token Reduction for Accelerating BERT Inference. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 5798–5809, Online. Association for Computational Linguistics.
Cite (Informal):
TR-BERT: Dynamic Token Reduction for Accelerating BERT Inference (Ye et al., NAACL 2021)
Copy Citation:
PDF:
https://aclanthology.org/2021.naacl-main.463.pdf
Video:
 https://aclanthology.org/2021.naacl-main.463.mp4
Code
 thunlp/TR-BERT
Data
HotpotQAIMDb Movie ReviewsNewsQARACETriviaQAWikiHop