TR-BERT: Dynamic Token Reduction for Accelerating BERT Inference

Deming Ye, Yankai Lin, Yufei Huang, Maosong Sun
5/25/2021
cs.CL

Official code: thunlp/TR-BERT (49 stars, Python, last commit 2022-05-25).

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

thunlp/TR-BERTOfficial100%

Source code for NAACL 2021 paper "TR-BERT: Dynamic Token Reduction for Accelerating BERT Inference"

497Python, Jupyter NotebookApr 10, 20214 years ago

Similar Papers

Cite this paper

@article{ye2021trbert,
  title  = {TR-BERT: Dynamic Token Reduction for Accelerating BERT Inference},
  author = {Deming Ye and Yankai Lin and Yufei Huang and Maosong Sun},
  year   = {2021},
  eprint = {2105.11618},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2105.11618}
}

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/2105.11618.svg)](https://codeofpaper.com/paper/2105.11618)

Discussion