COST-EFF: Collaborative Optimization of Spatial and Temporal Efficiency with Slenderized Multi-exit Language Models

Bowen Shen, Zheng Lin, Yuanxin Liu, Zhengxiao Liu, Lei Wang, Weiping Wang

Abstract

Pre-trained Language Models (PLMs) like BERT offer state-of-the-art performance but are limited by significant spatial (memory) and temporal (computation) overhead. We present COST-EFF, a framework that collaboratively optimizes these two dimensions of efficiency. By combining "static slenderization"—narrowing the model's width while maintaining depth—with "dynamic early exiting," COST-EFF allows for adaptive computation based on input complexity. Our results on the GLUE benchmark show that COST-EFF achieves 96.5% of BERT$_{Base}$ performance while utilizing only 1/8th of the parameters and 1/19th of the FLOPs, consistently outperforming existing static and dynamic compression methods.

Introduction

The deployment of large-scale PLMs on resource-constrained edge devices is hindered by two primary factors. First, spatial overhead: the millions of parameters in models like BERT require substantial storage. Second, temporal overhead: the fixed computational cost per inference, regardless of input difficulty, leads to inefficiency. While existing research has explored static compression (pruning, distillation) and dynamic acceleration (early exiting) independently, simply combining these techniques often results in performance degradation due to "inconsistency" between shallow and deep layers in capacity-limited models.

The COST-EFF Framework

COST-EFF addresses these challenges through a three-pronged approach that balances model capacity with inference speed.

Overview of the COST-EFF framework combining static slenderization and dynamic early exiting.

Static Slenderization

Unlike traditional "squat" models that reduce the number of layers, COST-EFF employs a "slender" architecture. It maintains the full depth of the transformer (e.g., 12 layers) but reduces the width of each layer. This is achieved via:

  1. Truncated Singular Value Decomposition (TSVD): Compressing the embedding matrix.
  2. Structured Pruning: Reducing the number of attention heads in Multi-Head Attention (MHA) and the hidden dimension of Feed-Forward Networks (FFN).

Dynamic Early Exiting

To optimize temporal efficiency, classifiers are attached to every layer. During inference, the model calculates the entropy (uncertainty) of the prediction at each layer. If the uncertainty falls below a predefined threshold, the model "exits" early, bypassing deeper layers for simpler inputs.

Collaborative Training

To mitigate the capacity issues of small models, COST-EFF uses a "Teacher Assistant" (a multi-exit BERT) to guide the slender student via knowledge distillation. Furthermore, Gradient Equilibrium is used to balance learning signals across all 12 classifiers, ensuring that shallow layers do not compromise the feature quality required by deeper layers.

Experimental Evaluation

The framework was evaluated on the GLUE benchmark, focusing on SST-2, MRPC, QNLI, and MNLI. These tasks represent a mix of single-sentence and sentence-pair classification challenges.

Key Results

COST-EFF demonstrates a superior trade-off between accuracy and efficiency compared to state-of-the-art baselines like TinyBERT and DeeBERT.

Performance vs. computation (MFLOPs) for COST-EFF and baselines across GLUE tasks.
  • Efficiency Gains: The COST-EFF${8\times}$ variant (8x parameter reduction) retains 96.5% of BERT${Base}$ performance while achieving a 19x reduction in total FLOPs.
  • Depth vs. Width: The "slender" 12-layer model consistently outperformed "squat" 4-layer models (e.g., TinyBERT$_4$), suggesting that depth is more critical than width for maintaining hierarchical feature extraction in compressed models.
  • Pareto Optimality: Across all tested GLUE tasks, COST-EFF consistently defines the Pareto frontier, providing the highest accuracy for any given computational budget.

Discussion and Limitations

While COST-EFF provides significant gains, certain challenges remain. Dynamic inference methods like early exiting are difficult to optimize in high-throughput batch processing environments, as different samples may exit at different layers. Additionally, while FLOPs are significantly reduced, actual wall-clock speedups depend on hardware-specific support for structured pruning. Future work will explore the application of slenderization to generative tasks (NLG) such as translation and summarization.

Summary updated

BibTeX
@inproceedings{shen2022cost,
  author = {Bowen Shen and Zheng Lin and Yuanxin Liu and Zhengxiao Liu and Lei Wang and Weiping Wang},
  title = {{COST-EFF: Collaborative Optimization of Spatial and Temporal Efficiency with Slenderized Multi-exit Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  url = {https://openreview.net/forum?id=kzgaZBdPJgs},
}
Figure