[Paper Review] DeeBERT: Dynamic Early Exiting for Accelerating BERT Inference
DeeBERT proposes a dynamic early exiting mechanism for BERT and RoBERTa models, inserting off-ramp classification heads after each transformer layer to allow samples to exit early if confident. This achieves up to ~40% inference speedup with minimal accuracy degradation, revealing layer-wise redundancy and enabling efficient, adaptive inference across NLP tasks.
Large-scale pre-trained language models such as BERT have brought significant improvements to NLP applications. However, they are also notorious for being slow in inference, which makes them difficult to deploy in real-time applications. We propose a simple but effective method, DeeBERT, to accelerate BERT inference. Our approach allows samples to exit earlier without passing through the entire model. Experiments show that DeeBERT is able to save up to ~40% inference time with minimal degradation in model quality. Further analyses show different behaviors in the BERT transformer layers and also reveal their redundancy. Our work provides new ideas to efficiently apply deep transformer-based models to downstream tasks. Code is available at https://github.com/castorini/DeeBERT.
Motivation & Objective
- To address the high inference latency of large pre-trained language models like BERT and RoBERTa, which hinders real-time deployment.
- To explore whether intermediate transformer layers in BERT contain sufficient representational capacity for early prediction.
- To develop a method that enables efficient, adaptive inference by allowing samples to exit early based on confidence, without retraining the full model.
- To analyze layer-wise behavior and redundancy in BERT and RoBERTa to understand when and why early exiting is effective.
Proposed method
- DeeBERT inserts a separate classification head (off-ramp) after each transformer layer in BERT and RoBERTa.
- All off-ramps and transformer layers are jointly fine-tuned on downstream datasets using cross-entropy loss for each off-ramp.
- During inference, a sample exits at the first off-ramp where prediction confidence exceeds a learned entropy threshold.
- The method uses a two-stage fine-tuning process: first, the final off-ramp is trained normally; second, intermediate off-ramps are fine-tuned while freezing earlier layers.
- An expected saving metric is introduced to analytically estimate inference efficiency, independent of runtime variability.
- Layerwise performance and exit frequency are analyzed to identify redundant layers and optimal exit points.
Experimental results
Research questions
- RQ1Can intermediate transformer layers in BERT and RoBERTa provide sufficient representational quality for early classification?
- RQ2How does the distribution of early exits vary across different NLP tasks and model variants?
- RQ3What is the trade-off between inference speedup and accuracy degradation when using early exiting?
- RQ4Which transformer layers are redundant, and what patterns emerge in their performance across layers?
- RQ5How does the entropy threshold influence the balance between efficiency and model quality?
Key findings
- DeeBERT achieves up to ~40% inference time reduction on BERT and RoBERTa across six GLUE benchmarks with minimal accuracy degradation.
- On the SST-2 dataset, DeeBERT reduces inference time by 21% for BERT-base and 26% for RoBERTa-base, with only 0.2% and 0.1% accuracy drop respectively.
- Layerwise analysis shows that RoBERTa exhibits a delayed performance improvement, with rapid gains after a few initial layers, while BERT shows a more gradual improvement.
- Both BERT-large and RoBERTa-large show signs of redundancy in their final layers, where performance gains plateau or slightly decline.
- Popular exit layers correspond to those that significantly improve over previous layers, and the entropy threshold effectively selects high-quality, early exit points.
- Expected saving metric correlates linearly with measured runtime savings, confirming the stability and reliability of the efficiency estimation.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.