Early Exiting with Ensemble Internal Classifiers

Tianxiang Sun, Yunhua Zhou, Xiangyang Liu, Xinyu Zhang, Hao Jiang, Zhao Cao, Xuanjing Huang, Xipeng QiuarXiv 2021

Abstract

Large-scale pre-trained language models (PLMs) like BERT and ALBERT have set new benchmarks in NLP but require substantial computational resources for inference. Early exiting is a promising technique to reduce latency by allowing samples to exit at intermediate layers. However, existing methods often train internal classifiers independently and rely on single-layer confidence for exit decisions. This paper proposes a novel framework that treats internal classifiers as an ensemble. By introducing a diversity loss ($L_{div}$) during training to reduce redundancy and a voting-based strategy during inference to leverage collective layer wisdom, the proposed method achieves superior accuracy-speed tradeoffs across various NLP benchmarks.

Introduction

The computational intensity of PLMs poses a significant challenge for real-time applications. Early exiting addresses this by attaching internal classifiers to intermediate layers, enabling the model to stop processing once a sufficient confidence threshold is met. Despite its popularity, current implementations suffer from two main drawbacks: (1) internal classifiers are trained without considering their relationship to one another, leading to redundant feature learning, and (2) exit decisions are typically local, ignoring the information accumulated in previous layers. This often results in "overthinking," where a correct early prediction is overturned by deeper layers.

Methodology

The authors address these issues through two primary innovations based on ensemble learning and information theory.

Diversity-Aware Training

To ensure that each internal classifier contributes unique information to the ensemble, a Diversity Loss ($L_{div}$) is introduced alongside the standard accuracy loss ($L_{rel}$). Derived from multi-information theory, $L_{div}$ encourages the probability distributions of adjacent or similar layers to diverge, forcing the model to learn a broader variety of features and preventing redundancy.

The training architecture incorporates a diversity loss ($L_{div}$) to encourage unique feature learning across internal classifiers.

Voting-Based Exiting

During inference, the model employs a robust voting mechanism. Instead of relying solely on the current layer's output, it aggregates predictions from all preceding layers using a weighted voting scheme. If a specific label reaches a predefined threshold of votes, the model exits. This approach mitigates the risk of a single layer's error causing a premature or incorrect exit, effectively recovering from "overthinking" scenarios.

Experimental Results

The method was evaluated on standard NLP tasks including binary classification (e.g., SST-2, MRPC) and multi-class classification (e.g., TREC, AG’s News) using ALBERT and BERT backbones.

Accuracy vs. Speed-up Ratio for BERT (a) and ALBERT (b). The proposed method (DeeBERT/DeeALBERT) consistently outperforms baselines and approaches the theoretical Oracle performance.

Key findings include:

  • Enhanced Accuracy: On the SST-2 sentiment task using ALBERT, the voting strategy achieved 93.5% accuracy at a 1.5x speedup, surpassing previous state-of-the-art results.
  • Robust Efficiency: For multi-class tasks like TREC, the model maintained high accuracy (97.0%) while doubling inference speed (2.0x speedup).
  • Consistency: The diversity loss improved performance regardless of the specific exit strategy used, indicating its fundamental value as a training objective. It acts as a form of dynamic label smoothing, alleviating overconfidence in deep networks.

Discussion and Limitations

While the results are promising, the authors identify several hurdles for widespread adoption. The method introduces new hyperparameters, such as $\lambda$ (balancing accuracy and diversity) and $k$ (weighting layer importance), which require additional tuning. Furthermore, comparing layers during training adds computational overhead, although inference remains fast. Future work will explore automating hyperparameter selection and extending the framework to generative (GPT-style) architectures.

Summary updated

BibTeX
@misc{sun2021early,
  author = {Tianxiang Sun and Yunhua Zhou and Xiangyang Liu and Xinyu Zhang and Hao Jiang and Zhao Cao and Xuanjing Huang and Xipeng Qiu},
  title = {{Early Exiting with Ensemble Internal Classifiers}},
  year = {2021},
  eprint = {2105.13792},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2105.13792},
}
Figure