Skip to main content
QUICK REVIEW

[Paper Review] TR-BERT: Dynamic Token Reduction for Accelerating BERT Inference

Deming Ye, Yankai Lin|arXiv (Cornell University)|May 25, 2021
Topic ModelingComputer Science48 references7 citations
TL;DR

TR-BERT proposes a dynamic token reduction method to accelerate BERT inference by learning, via reinforcement learning, which tokens to retain at each layer based on their task relevance. It achieves 2–5× speedup with minimal accuracy drop, especially benefiting long-sequence tasks by reducing quadratic self-attention complexity through selective token propagation.

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.

Motivation & Objective

  • To address the high inference latency of pre-trained language models (PLMs) in resource-limited environments.
  • To overcome the limitations of fixed-layer pruning, which uniformly reduces model depth and harms performance on complex tasks.
  • To enable adaptive computation per token by dynamically selecting which tokens to propagate through deeper layers.
  • To improve efficiency in long-text scenarios where self-attention scales quadratically with sequence length.
  • To provide a flexible, on-demand speed-accuracy trade-off for real-world deployment.

Proposed method

  • TR-BERT formulates token reduction as a multi-step selection problem, where each token is either selected or skipped at each layer.
  • It employs a policy network in a reinforcement learning framework to learn dynamic token selection strategies based on task-specific importance.
  • The RL agent receives a reward combining prediction confidence and a penalty on the number of selected tokens to balance speed and accuracy.
  • Tokens deemed less important are pruned early, reducing subsequent computation and avoiding redundant self-attention operations.
  • The method operates at the token level, allowing fine-grained control over computation per input token, unlike layer-level pruning.
  • The framework is plug-and-play, requiring no retraining of the base BERT model and compatible with existing PLMs.

Experimental results

Research questions

  • RQ1Can dynamic, token-level pruning improve inference speed without sacrificing model performance?
  • RQ2How does dynamic token selection based on task relevance compare to fixed-layer or layer-wise pruning?
  • RQ3Can reinforcement learning effectively learn token importance signals without human-annotated supervision?
  • RQ4To what extent does token-level pruning improve efficiency in long-sequence NLP tasks?
  • RQ5Can the method achieve a flexible speed-accuracy trade-off across diverse downstream tasks?

Key findings

  • TR-BERT achieves 2–5× faster inference across eleven NLP benchmarks, depending on the desired accuracy level.
  • On question-answering tasks, TR-BERT outperforms baseline methods, especially in complex reasoning scenarios where fixed pruning fails.
  • For long-text tasks (e.g., 1,024 input tokens), TR-BERT achieves higher performance with significantly reduced inference time compared to vanilla BERT.
  • The model maintains high prediction confidence on pruned sequences, indicating effective selection of semantically meaningful tokens.
  • The RL-based token selection policy learns to preserve task-relevant tokens such as question words and sentiment indicators without human annotations.
  • The method demonstrates robustness across diverse NLP tasks, including text classification, natural language inference, and question answering.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.