Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

TR-BERT: Dynamic Token Reduction for Accelerating BERT Inference

About

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.

Deming Ye, Yankai Lin, Yufei Huang, Maosong Sun• 2021

Related benchmarks

TaskDatasetResultRank
Sentiment AnalysisIMDB (test)
Accuracy93.2
248
Natural Language InferenceMNLI GLUE matched mismatched average (test)
Accuracy84.8
9
Topic ClassificationAG's news standard (test)
Accuracy93.2
5
Topic ClassificationDBpedia standard (test)
Accuracy98.9
5
Hate speech classificationHateXplain standard (test)
Accuracy67.9
5
Question Answering NLIQNLI GLUE (test)
Accuracy0.89
5
Paraphrase DetectionMRPC GLUE (test)
F1 Score81.9
5
Sentiment AnalysisSST-2 GLUE (test)
Accuracy92.1
5
Showing 8 of 8 rows

Other info

Follow for update