A Simple Hash-Based Early Exiting Approach For Language Understanding and Generation

Tianxiang Sun, Xiangyang Liu, Wei Zhu, Zhichao Geng, Lingling Wu, Yilong He, Yuan Ni, Guotong Xie, Xuanjing Huang, Xipeng Qiu

Introduction

Large pre-trained language models (PLMs) like BERT, RoBERTa, and BART have revolutionized NLP but at a high inference cost. Early exiting—stopping computation at shallower layers for "easy" inputs—is a promising solution. However, existing approaches typically rely on "learn-to-exit" modules or complex heuristics that add parameters and require extensive tuning. This paper introduces HASHEE (Hash-based Early Exiting), a simple, parameter-free method that outperforms complex dynamic exiting baselines by challenging the assumption that instance difficulty is learnable.

The "Difficulty" Myth

The core motivation for HASHEE stems from a critical observation: modern neural networks are surprisingly poor at identifying which inputs are "hard" for them. The authors conducted a sanity check, training various models (from simple linear classifiers to BERT) to predict instance difficulty based on human disagreement or model failure. They found that these models barely outperformed a majority-class baseline. This suggests that the overhead of training complex "exit-gates" is often wasted, as they fail to accurately estimate the necessity of deeper computation.

HASHEE: Consistency over Prediction

Instead of attempting to predict difficulty on the fly, HASHEE relies on the principle of consistency. It assumes that if a token is processed at a specific layer during training, it should remain at that layer during inference.

The HASHEE architecture uses a hash table to map tokens to specific exit layers, allowing for efficient token-level early exiting without additional parameters.

The workflow is straightforward:

  1. Hash Function: Every token in the vocabulary is mapped to a specific layer via a hash function. The most effective strategy is Frequency Hash, which assigns frequent tokens (e.g., "the", "is") to earlier layers and rare tokens to later ones.
  2. Token-Level Exiting: Computation is performed at the token level. Once a token reaches its assigned exit layer, its representation is copied to subsequent layers, bypassing further self-attention or feed-forward operations.
  3. Parameter-Free: HASHEE requires no internal classifiers or additional training parameters, making it highly efficient and easy to integrate into existing architectures.

Experimental Evaluation

The authors evaluated HASHEE across a wide range of Natural Language Understanding (NLU) and generation tasks.

Performance on NLU

On the ELUE benchmark, HASHEE achieved a significant breakthrough with an ELUE score of 1.20, compared to 0.00 for the previous state-of-the-art, ElasticBERT. In specific tasks like SST-2 sentiment analysis, HASHEE provided a 4.8x speedup while maintaining 85.5% accuracy—far exceeding the performance of static pruned models like a 3-layer BERT.

Accuracy vs. Speed-up comparison across various PLMs. HASHEE consistently provides a better Pareto frontier than existing dynamic exiting methods like FastBERT and PABEE.

Text Generation and Inference Speed

For summarization tasks using BART, HASHEE reduced FLOPs by approximately 50% while retaining 97% of the original ROUGE-1 score. Crucially, HASHEE excels in real-world wall-clock time. Unlike other dynamic methods that break GPU parallelization because different instances exit at different times, HASHEE’s fixed lookup table allows for efficient batch-level processing. On an RTX 3090, HASHEE demonstrated superior throughput, especially as batch sizes increased.

Conclusion

HASHEE demonstrates that simplicity can be more effective than complexity in model acceleration. By replacing unreliable difficulty prediction with a consistent, hash-based token assignment, HASHEE achieves state-of-the-art speedups without the need for extra parameters or complex tuning. While future work may explore context-sensitive hashing, HASHEE currently stands as a robust and efficient baseline for practical PLM deployment.

Summary updated

BibTeX
@inproceedings{sun2022simple,
  author = {Tianxiang Sun and Xiangyang Liu and Wei Zhu and Zhichao Geng and Lingling Wu and Yilong He and Yuan Ni and Guotong Xie and Xuanjing Huang and Xipeng Qiu},
  title = {{A Simple Hash-Based Early Exiting Approach For Language Understanding and Generation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.findings-acl.189},
}
Figure