Abstract
Given a pretrained encoder-based language model, how can we accurately compress it without retraining? Retraining-free structured pruning algorithms are crucial in pretrained language model compression due to their significantly reduced pruning cost and capability to prune large language models. However, existing retraining-free algorithms encounter severe accuracy degradation, as they fail to handle pruning errors, especially at high compression rates. In this paper, we propose K-prune (Knowledge-preserving pruning), an accurate retraining-free structured pruning algorithm for pretrained encoder-based language models. K-prune focuses on preserving the useful knowledge of the pretrained model to minimize pruning errors through a carefully designed iterative pruning process composed of knowledge measurement, knowledge-preserving mask search, and knowledge-preserving weight-tuning. As a result, K-prune shows significant accuracy improvements up to 58.02%p higher F1 score compared to existing retraining-free pruning algorithms under a high compression rate of 80% on the SQuAD benchmark without any retraining process.
Introduction
Pre-trained Language Models (PLMs) like BERT have revolutionized NLP, but their massive size poses significant deployment challenges, particularly on edge devices. Pruning—the removal of redundant attention heads or neurons—is a standard compression technique. However, researchers face a difficult trade-off: retraining-based pruning is accurate but computationally prohibitive (requiring days of GPU time), while retraining-free (one-shot) pruning is fast but suffers from catastrophic accuracy collapse at high compression rates (e.g., 80% FLOPs reduction).
K-prune (Knowledge-preserving pruning) bridges this gap, achieving the accuracy of retraining-based methods with the extreme efficiency of one-shot approaches.
Methodology
K-prune departs from traditional one-shot methods by employing an iterative, sublayer-wise approach. Instead of pruning the entire model at once, it processes the model from the bottom sublayer to the top, performing a localized "repair" at each step to prevent error accumulation.
The process involves three core components:
- Knowledge Measurement: Quantifies the importance of each unit (head or neuron) by measuring the distortion caused by its removal on both final predictions (predictive knowledge) and intermediate layer outputs (representational knowledge).
- Knowledge-preserving Mask Search (KPMS): Selects units for pruning based on their "global importance" relative to all remaining unpruned layers.
- Knowledge-preserving Weight-tuning (KPWT): This is the method's "secret sauce." It treats weight recovery as a linear least squares problem. By using a fast linear solver to adjust remaining weights to mimic the original model's outputs, K-prune achieves "retraining-free" speeds—tuning takes less than a second per sublayer on standard hardware.
Experimental Evaluation
The authors evaluated K-prune across a wide range of benchmarks, including the GLUE suite (MRPC, QQP, SST-2, STS-B, MNLI, QNLI) and SQuAD v1.1 & v2.0 for extractive question answering. They also tested the method on billion-scale decoder models like OPT-2.7B.
Key Results
K-prune demonstrates a significant performance advantage over existing retraining-free methods, particularly as the compression rate increases.
- Massive Accuracy Gains: On SQuAD 1.1 at 80% compression, K-prune achieved a 58.02%p higher F1 score than the next best retraining-free method.
- Extreme Efficiency: The method is up to 422x faster than retraining-based methods like DynaBERT while maintaining comparable accuracy.
- Inference Speedup: Pruned models were up to 2.93x faster during inference than the original uncompressed models.
- Scalability: Preliminary results on OPT-2.7B show that the method scales effectively to larger decoder-based architectures with negligible performance loss at 20% pruning.
Conclusion and Future Work
K-prune redefines the limits of retraining-free pruning by conceptualizing pruning error as knowledge loss and addressing it through iterative linear weight-tuning. While highly effective for encoder-based models, future work will focus on extending these techniques to the latest generation of massive decoder-only LLMs and exploring data-free variants to remove the dependency on small sample datasets.
Summary updated