SlowBERT: Slow-down Attacks on Input-adaptive Multi-exit BERT

Shengyao Zhang, Xudong Pan, Mi Zhang, Min YangACL 2023

Abstract

Efficiency is a primary goal in modern Natural Language Processing (NLP). Large-scale models like BERT are computationally intensive, prompting the development of "input-adaptive" variants known as multi-exit BERTs. These models utilize early-exit mechanisms to process simple inputs faster. However, this efficiency introduces a new attack surface. This paper presents SlowBERT, a novel adversarial attack that imperceptibly modifies input text to maximize computational costs. By forcing models to bypass early-exit shortcuts, SlowBERT increases inference latency by up to 4.57× and significantly degrades model accuracy, revealing a critical trade-off between efficiency and security.

Introduction

As NLP models grow in size, deploying them on resource-constrained edge devices or high-throughput cloud services requires optimization. Multi-exit BERT architectures address this by placing internal classifiers at various layers, allowing the model to "exit" early if a prediction can be made with high confidence. While this "green AI" approach saves energy and time, it assumes inputs are benign. SlowBERT challenges this assumption by demonstrating that a malicious actor can craft inputs that look normal to humans but are computationally "heavy" for the model.

Understanding Multi-exit Vulnerabilities

Multi-exit models typically rely on two primary strategies to decide when to stop processing:

  1. Confidence-based: The model exits if the prediction probability at a given layer exceeds a predefined threshold $T$.
  2. Patience-based: The model exits if the predictions of $C$ consecutive layers remain consistent.
Overview of confidence-based and patience-based early-exit mechanisms in multi-exit BERT.

SlowBERT exploits these mechanisms by introducing subtle perturbations that lower prediction confidence or create disagreement between layers, effectively disabling the "fast-track" option.

The SlowBERT Attack Methodology

The researchers developed a rank-and-substitute algorithm to generate these "slow-down" texts.

Efficiency Relevance Ranking

The attack first identifies "efficiency-critical" words—those most responsible for triggering an early exit. By masking words individually and measuring the resulting shift in exit position, the algorithm prioritizes words that, when altered, force the model deeper into its architecture.

Word Substitution

Once target words are identified, SlowBERT applies character-level (e.g., typos like "mvoie") or word-level (synonym replacement) changes. These modifications are designed to be semantically similar to the original text, ensuring the attack remains stealthy to human observers.

The Black-Box Time Oracle

A key contribution of this work is the ability to attack models without internal access. The authors identified a strong linear correlation between inference time and exit depth. By using a time-based approximation and K-means clustering, SlowBERT can estimate the internal exit layer of a remote model, making it a viable threat against commercial APIs.

Experimental Results

The attack was evaluated on the GLUE benchmark using SST-2 and MRPC datasets against BERT-base and ALBERT-base architectures.

Massive Latency Spikes

The primary goal of SlowBERT is to maximize resource consumption. In testing, the attack increased average inference costs by up to 4.57×. For large-scale deployments, such an increase could lead to significant financial costs and service degradation.

Distribution of exit positions for original vs. slow-down texts, showing the shift toward the final layer.

As shown in the figure above, the attack successfully shifts the distribution of exit positions from early layers (1-3) to the final layer (12), effectively neutralizing the benefits of the multi-exit architecture.

Collateral Accuracy Loss

Beyond slowing down the model, the attack also caused accuracy to drop by as much as 30%. This suggests that the features used for early exits are also critical for robust classification.

Conclusion

SlowBERT demonstrates that efficiency-oriented optimizations in NLP models can be weaponized. The success of the black-box "time oracle" attack highlights that even hidden models are vulnerable to side-channel analysis. Future work must focus on developing defenses, such as adversarial training, to ensure that the pursuit of efficiency does not come at the cost of security and robustness.

Summary updated

BibTeX
@inproceedings{zhang2023slowbert,
  author = {Shengyao Zhang and Xudong Pan and Mi Zhang and Min Yang},
  title = {{SlowBERT: Slow-down Attacks on Input-adaptive Multi-exit BERT}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  url = {https://openreview.net/forum?id=d_e6A5_gMMG},
}
Figure