Length-Adaptive Distillation: Customizing Small Language Model for Dynamic Token Pruning

Chang Liu, Chongyang Tao, Jianxin Liang, Jiazhan Feng, Tao Shen, Quzhe Huang, Dongyan Zhao

Abstract

Length-Adaptive Distillation (LAD) addresses the sub-optimality of sequential model compression and dynamic token pruning. By training a student model to reconstruct full teacher representations from pruned sequences, LAD creates customized small models that maintain high accuracy while achieving significant inference speedups of up to 6.1x. This framework effectively bridges the "compatibility gap" where standard compressed models fail to handle the missing information inherent in dynamic computation.

Introduction

The deployment of Large Language Models (LLMs) in resource-constrained environments typically relies on two distinct strategies: model compression (reducing layers or dimensions) and dynamic computation (e.g., token pruning). Traditionally, these are applied as a pipeline: a model is first compressed and then pruned. However, standard compressed models are trained on full sequences; when tokens are dropped during inference, their internal representations degrade significantly. Length-Adaptive Distillation (LAD) is proposed to co-design the distillation and pruning processes, ensuring the student model is inherently robust to token removal.

Methodology

LAD employs a two-stage distillation process designed to align student representations with a teacher model even under aggressive pruning conditions.

Overview of the Length-Adaptive Distillation (LAD) framework, illustrating the dual-branch student training and the teacher-as-decoder reconstruction mechanism.

Stage 1: General Distillation

The student model is trained on large-scale corpora (Wikipedia and BookCorpus) using two parallel branches: one processing full text and another applying dynamic token pruning. A key innovation is the Reconstruction Trick, where the student uses the teacher's final layer as a frozen decoder to reconstruct full representations from pruned inputs. This is complemented by a token-level contrastive loss to align semantic nuances between the student and teacher.

Stage 2: Task-Specific Distillation

The model is fine-tuned on downstream tasks, focusing on the classification token and utilizing data augmentation to maintain robustness. Finally, an evolutionary search algorithm identifies optimal layer-wise pruning configurations to maximize the speed-to-accuracy trade-off for specific deployment targets.

Evaluation and Results

The framework was evaluated on the GLUE benchmark across various tasks including SST-2, MRPC, MNLI, and QNLI.

Accuracy vs. FLOPs trade-offs for LAD compared to baselines across MRPC, RTE, QNLI, and MNLI tasks.

LAD consistently outperforms state-of-the-art baselines like TinyBERT and MiniLMv2. Notably, on the MRPC task, LAD achieved a 6.1x speedup with a 2.1% accuracy improvement over static models. On the RTE task, it maintained stability even at a 7.8x acceleration rate, where standard models typically fail. These results demonstrate that LAD effectively bridges the compatibility gap between compression and pruning.

Key Insights

  • Token Pruning as Regularization: Training with high pruning ratios surprisingly improves overall performance, suggesting that learning from incomplete information forces the model to develop more robust representations.
  • Teacher-as-Decoder: Leveraging the teacher's final layer provides a high-quality reconstruction target without adding parameters to the student, maintaining efficiency.

Limitations and Future Work

The primary limitation is the computational overhead during training due to the dual-branch strategy. Future work aims to unify these branches for more efficient training. Additionally, while LAD is highly effective for encoder-only architectures (RoBERTa-style), extending this logic to generative decoder-only models (like GPT) remains an open research challenge.

Summary updated

BibTeX
@inproceedings{liu2023length,
  author = {Chang Liu and Chongyang Tao and Jianxin Liang and Jiazhan Feng and Tao Shen and Quzhe Huang and Dongyan Zhao},
  title = {{Length-Adaptive Distillation: Customizing Small Language Model for Dynamic Token Pruning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.294},
}
Figure