A Global Past-Future Early Exit Method for Accelerating Inference of Pre-trained Language Models

Kaiyuan Liao, Yi Zhang, Xuancheng Ren, Qi Su, Xu Sun, Bin He

TL;DR

Researchers have developed a "Global Past-Future" early exit strategy that significantly speeds up Pre-trained Language Models (PLMs) like BERT without the usual steep drop in accuracy. By combining information from all previous layers and using imitation learning to "predict" the features of future layers, the model can make much more informed decisions about when to stop processing.

What Problem Does This Paper Address?

Large-scale pre-trained models are powerful but computationally expensive and slow during inference. "Early exit" is a popular solution: instead of passing an input through all 12 (or 24) layers of a model, the system attaches classifiers to intermediate layers. If the model is confident enough at layer 6, it "exits" and gives an answer, saving the time and energy required for layers 7 through 12.

However, existing early exit methods have a "short-sightedness" problem. They typically only look at the local state of the current layer to make a prediction. This ignores two things:

  1. The Past: The rich, hierarchical linguistic information captured by all the layers the input has already passed through.
  2. The Future: The high-level semantic features that only emerge in deeper layers, which are technically inaccessible if you exit early.

As a result, when you try to push these models to go faster (higher speed-up ratios), their accuracy usually falls off a cliff.

Comparison of early exit strategies: (a) Local exit (DeeBERT), (b) Global Past, and (c) Global Past-Future.

Methods

The authors propose a novel framework that looks both backward and forward:

  • Incorporation of Past States: Instead of using just the current layer's output, they aggregate all available "past" states. They tested several strategies (pooling, LSTMs, etc.) and found that simply concatenating all previous layer states worked best, allowing the model to leverage the full hierarchy of features.
  • Imitation of Future States: This is the most innovative part. Since future layers haven't been processed yet, their states are unknown. The authors use imitation learning to train "learners" at each layer. These learners try to approximate what the deeper, uncomputed layers would have produced. During training, the model uses a cosine similarity loss to make these approximations as close to the "real" future states as possible.
Detailed architecture of the Global Past-Future framework showing how future states are imitated using learners ($L$).
  • Adaptive Merging Gate: Because "real" past data is more reliable than "approximated" future data, the model uses a learnable gating mechanism. This gate dynamically weights the past and future information based on the specific input, creating a unified "global" representation for the final prediction.
  • Smart Fine-tuning: To prevent the model from over-fitting to downstream tasks and losing its general knowledge, they use a probabilistic freezing technique where shallower layers are more likely to be frozen during fine-tuning.

Datasets and Evaluation

The method was evaluated on the GLUE (General Language Understanding Evaluation) benchmark, specifically focusing on six diverse classification tasks: SST-2 (Sentiment analysis), MRPC & QQP (Paraphrase detection), QNLI & RTE (Natural language inference), and MNLI (Multi-genre natural language inference). They tested their approach across three different backbone architectures: BERT, RoBERTa, and ALBERT.

Key Insights and Ideas

  • Global is better than Local: The "aha moment" is that an early exit shouldn't just be a shortcut; it should be an informed decision based on the model's entire journey through the layers.
  • The Future can be Guessed: You don't actually need to compute the deep layers to benefit from them. By training the model to "hallucinate" high-level features early on, shallow layers can achieve performance previously reserved for deep layers.
  • Robustness at Speed: While standard methods (like DeeBERT or PABEE) perform okay at 1.5x speedups, they fail at 3x. The Past-Future method remains remarkably stable even when exiting very early, suggesting that the "approximated future" provides the necessary semantic context that shallow layers usually lack.

Key Results

  • Superior Accuracy: At a 2x speed-up, the proposed method outperformed previous state-of-the-art early exit methods (DeeBERT and PABEE) across almost all GLUE tasks. For example, on MNLI, it achieved ~83% accuracy compared to DeeBERT's ~74%.
  • High-Speed Stability: At a 3x speed-up, the gap widened significantly. While baselines saw dramatic performance degradation, the Past-Future method maintained high accuracy, proving it is much more robust for aggressive acceleration.
  • Backbone Agnostic: The improvements were consistent whether using BERT, the more optimized RoBERTa, or the parameter-efficient ALBERT.

Limitations and Future Work

  • Training Overhead: While inference is faster, the training process is more complex, requiring multiple imitation losses and managing adaptive gates.
  • Architecture Specificity: The current work focuses on classification tasks. Extending this "Global Past-Future" logic to generative tasks (like translation or summarization) remains a challenge.
  • Learner Complexity: The "future learners" are currently simple feed-forward networks. Exploring more sophisticated architectures for these learners might yield even better approximations.

Summary updated

BibTeX
@inproceedings{liao2021global,
  author = {Kaiyuan Liao and Yi Zhang and Xuancheng Ren and Qi Su and Xu Sun and Bin He},
  title = {{A Global Past-Future Early Exit Method for Accelerating Inference of Pre-trained Language Models}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.naacl-main.162},
}
Figure