Introduction
Pre-trained Transformer models like BERT have set new benchmarks in sequence labeling tasks, such as Named Entity Recognition (NER) and Part-of-Speech (POS) tagging. However, their high computational cost poses a significant barrier to real-time deployment. While "early-exit" strategies—where a model stops processing once it reaches a confidence threshold—have been successful for sequence-level tasks like sentiment analysis, applying them to token-level sequence labeling is more complex.
The Limitation of Sentence-Level Exit
Standard early-exit methods typically treat the entire sentence as a single unit, known as Sentence-level Early-Exit (SENTEE). This approach is often inefficient for sequence labeling because sentences contain a mix of "easy" tokens (e.g., common determiners) and "hard" tokens (e.g., ambiguous proper nouns). In SENTEE, the entire sequence is either forced to wait for the most uncertain token to reach a confidence threshold, or it exits prematurely and mislabels difficult tokens.
Proposed Method: TOKEE
To address these inefficiencies, the authors introduce TOKEE (Token-level Early-Exit). This mechanism allows individual tokens to exit at different layers of the BERT model based on their specific processing needs.
Window-Based Uncertainty and Halt-and-Copy
TOKEE employs two key innovations to maintain accuracy while reducing computation:
- Window-Based Uncertainty: Instead of relying solely on a single token's confidence, TOKEE evaluates a local window of neighboring tokens. A token only exits if its entire neighborhood demonstrates high confidence, ensuring that local context is sufficiently captured.
- Halt-and-Copy: When a token exits, its hidden state is "frozen" and copied to subsequent layers. This allows active "hard" tokens to continue attending to the exited "easy" tokens without re-computing the representations of the latter, reducing the self-attention complexity from $O(N^2)$ to $O(NM)$, where $M$ is the number of active tokens.
Experimental Evaluation
The researchers evaluated TOKEE across ten datasets covering NER, POS tagging, and Chinese Word Segmentation. The experiments utilized various architectures, including BERT, RoBERTa, and ALBERT, to demonstrate the method's versatility.
Key Results and Performance
TOKEE achieves significant inference acceleration, saving between 66% and 75% of computational costs (3x to 4x speedup) with minimal impact on F1 scores. Notably, TOKEE maintains a much higher "speedup ceiling" than SENTEE. As shown in the performance curves for the CoNLL2003 dataset, SENTEE's accuracy collapses at high speedup ratios because it forces the entire model to be shallow. In contrast, TOKEE remains robust by keeping deep layers active only for the most difficult tokens.
Furthermore, TOKEE consistently outperforms standard model compression techniques like DistilBERT. At a 4x speedup on the Ontonotes 4.0 NER task, TOKEE maintained an F1 score nearly 9 points higher than a 3-layer DistilBERT.
Conclusion and Future Directions
TOKEE provides a powerful framework for accelerating sequence labeling by allowing fine-grained, token-level control over model depth. Future work may explore integrating label dependencies into the exit criterion or adapting the mechanism for complex decoders like Conditional Random Fields (CRFs). While theoretical FLOPs reduction is substantial, optimizing hardware-level dynamic branching remains a key step for maximizing real-world "wall-clock" speedups.
Summary updated