Accurate Retraining-free Pruning for Pretrained Encoder-based Language Models

Seungcheol Park, Hojun Choi, U Kang

TL;DR

K-prune (Knowledge-preserving pruning) is a new "retraining-free" method that compresses large language models by up to 80% without the massive accuracy drops typical of one-shot pruning. By using a clever iterative process and fast linear algebra to "reconstruct" lost knowledge layer-by-layer, it achieves performance comparable to expensive retraining-based methods at a fraction of the computational cost.

What Problem Does This Paper Address?

Pretrained Language Models (PLMs) like BERT are incredibly powerful but also incredibly large, making them difficult to deploy on edge devices or in low-latency environments. To fix this, researchers use structured pruning—removing entire neurons or attention heads to make the model smaller and faster.

Currently, developers face a difficult choice between two paradigms:

  1. Retraining-based pruning: Highly accurate, but requires massive amounts of data and GPU time to "re-teach" the model after it has been cut.
  2. Retraining-free (One-shot) pruning: Fast and cheap, but accuracy falls off a cliff once you try to remove more than a small percentage of the model.

The authors identify the core issue as "pruning errors." When a piece of a model is cut, the output of that layer changes slightly. These tiny distortions accumulate across dozens of layers, eventually leading to a "knowledge loss" that the model cannot recover from without full retraining.

Methods

K-prune introduces an iterative, sublayer-wise pruning process that moves from the bottom of the model to the top. It consists of three main pillars:

K-Prune Methodology
  1. Knowledge Measurement: Instead of just looking at weight magnitude, K-prune measures how much "knowledge" a unit holds. It evaluates predictive knowledge (how much a unit affects the final label) and representational knowledge (how much it affects the internal features of its own layer).
  2. Knowledge-preserving Mask Search (KPMS): In each step, the algorithm looks at the "global importance" of all remaining units across all layers. It then identifies the least important units in the current target layer to prune, ensuring the most vital information is kept intact.
  3. Knowledge-preserving Weight-tuning (KPWT): This is the breakthrough step. After pruning units in a layer, K-prune doesn't use standard, slow backpropagation. Instead, it formulates a linear least-squares problem to adjust the weights of the remaining units so that the layer's output matches the original unpruned version as closely as possible. This process takes less than a second on a standard desktop.

Datasets

The authors evaluated K-prune on standard NLP benchmarks using BERT and DistilBERT:

  • GLUE Benchmark: Includes tasks like MRPC (paraphrase), SST-2 (sentiment), and MNLI (inference).
  • SQuAD v1.1 & v2.0: The gold standard for question-answering tasks.
  • Wiki-text2: Used for preliminary testing on decoder-based models (OPT-1.3B and 2.7B).

Key Insights and Ideas

  • Representational Knowledge is Key: Previous methods focused mostly on the final output. K-prune shows that preserving the "internal features" (the intermediate representations) is actually more important for preventing error accumulation at high compression rates.
  • Iterative Refinement > One-shot Cutting: By pruning a little bit at a time and immediately "fixing" the layer using weight-tuning, the model never drifts too far from its original state.
  • Efficiency through Linear Algebra: The use of a linear solver (least squares) instead of gradient descent is a massive win. It allows the model to "recover" from pruning using only a tiny sample of data (about 0.6% of the original training set) in seconds.

Key Results

  • Massive Accuracy Gains: At an 80% compression rate (reducing FLOPs by 80%), K-prune achieved an F1 score 58.02% points higher than existing retraining-free methods on the SQuAD benchmark.
Accuracy vs. Reduced FLOPs
  • Retraining Performance at 1/400th the Cost: K-prune matches or beats the accuracy of state-of-the-art retraining-based methods (like DynaBERT) while being up to 422x faster to prune.
  • Real-world Speedup: Models compressed with K-prune showed up to 2.93x faster inference on commodity hardware (NVIDIA 1080 Ti) compared to the original unpruned models.
  • LLM Scalability: While designed for encoder models, early tests on OPT (a decoder-based LLM) showed K-prune could prune 20% of the model with negligible performance degradation.

Limitations and Future Work

  • Encoder Focus: The bulk of the paper focuses on BERT-style (encoder) models. While they show promising results on OPT, more work is needed to see if this holds up for massive 70B+ parameter decoder-only models like Llama-3.
  • Hyperparameter Tuning: The method relies on a few balance coefficients ($\lambda$ and $\mu$) to weight different types of knowledge. While they provide recommended values, these might need adjustment for entirely new architectures.
  • Future Direction: The authors suggest extending this framework specifically for decoder-based Large Language Models (LLMs) to address the growing need for efficient generative AI.

Summary updated

BibTeX
@inproceedings{park2024accurate,
  author = {Seungcheol Park and Hojun Choi and U Kang},
  title = {{Accurate Retraining-free Pruning for Pretrained Encoder-based Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=s2NjWfaYdZ},
}
Figure