LightPAFF: A Two-Stage Distillation Framework for Pre-training and Fine-tuning

Kaitao Song, Hao Sun, Xu Tan, Tao Qin, Jianfeng Lu, Hongzhi Liu, Tie-Yan LiuarXiv 2020

Abstract

Large-scale pre-trained language models (PLMs) such as BERT and GPT-2 have significantly advanced natural language processing. However, their immense parameter counts pose substantial challenges for deployment on resource-constrained devices. This paper introduces LightPAFF, a novel two-stage knowledge distillation framework designed to compress large PLMs. By performing distillation during both the pre-training and fine-tuning phases, LightPAFF effectively transfers both general linguistic knowledge and task-specific expertise to a smaller student model. Experimental results demonstrate that LightPAFF can reduce model size by 5x and increase inference speed by up to 7x while retaining approximately 99.5% of the teacher model's performance.

Introduction

The prevailing paradigm in NLP involves pre-training a large model on massive corpora followed by fine-tuning on specific downstream tasks. While effective, the resulting models—often containing hundreds of millions or billions of parameters—are frequently too large for mobile or low-latency environments. Standard BERT-base models, for instance, contain 110 million parameters, while GPT-2 can exceed 1.5 billion.

Previous efforts to mitigate this through Knowledge Distillation (KD) typically focused only on the fine-tuning stage. However, starting a small student model from scratch during fine-tuning often results in a significant performance gap, as the student misses the foundational linguistic knowledge acquired by the teacher during its extensive pre-training. LightPAFF addresses this by integrating distillation into the entire lifecycle of the model.

Methodology: The Two-Stage Pipeline

The core of LightPAFF is a two-stage distillation process that ensures the student model receives a comprehensive "education" from the larger teacher model.

The LightPAFF framework involves distillation at both the pre-training and fine-tuning stages to bridge the accuracy gap between large and small models.

1. Pre-training Distillation

Instead of training a small model from scratch on raw text, LightPAFF uses a pre-trained teacher to guide the student. During this stage, the student model is trained not only to predict tokens but also to match the teacher's full probability distribution across the vocabulary. This process transfers "general wisdom" and linguistic features, providing the student with a superior initialization for downstream tasks.

2. Fine-tuning Distillation

Once the general knowledge is transferred, the framework moves to task-specific distillation. The large teacher is first fine-tuned on a specific dataset (e.g., sentiment analysis). Subsequently, the pre-distilled student is fine-tuned while being forced to mimic the outputs of the fine-tuned teacher. To further enhance performance, unlabeled data is utilized during this stage, allowing the student to observe the teacher's logic across a broader range of inputs.

Experimental Results

The authors evaluated LightPAFF across three major architectures: BERT (understanding), GPT-2 (modeling), and MASS (sequence-to-sequence).

Performance and Efficiency

LightPAFF consistently achieved "teacher-level" performance with significantly fewer resources:

  • Model Compression: Parameters were reduced by nearly 5x (e.g., from 110M to 25M for BERT-base).
  • Inference Speedup: The framework achieved a 5x to 6x speedup on GPUs and approximately a 7x speedup on CPUs.
  • Accuracy Retention: Across various tasks, LightPAFF maintained over 99% of the teacher's accuracy. For example, on the SST-2 sentiment task, the student achieved 92.9% accuracy compared to the teacher's 93.5%.

Robustness and the Impact of KD

A key finding was the importance of the "head start" provided by pre-training distillation. Ablation studies indicated that skipping this stage leads to a marked decrease in final accuracy.

Comparison of model performance (Accuracy for BERT, Perplexity for GPT-2) with and without knowledge distillation across different noise levels (standard variance σ).

As shown in the experimental analysis, models trained with KD (blue lines) consistently outperform those without KD (red lines), especially as the complexity or noise in the task increases. This highlights the effectiveness of the distillation process in stabilizing and improving the student model's performance.

Conclusion

LightPAFF demonstrates that a two-stage distillation approach is highly effective for compressing large-scale language models without sacrificing significant performance. By leveraging both pre-training and fine-tuning distillation, along with unlabeled data, the framework makes massive models viable for real-world, resource-constrained applications. Future work will explore combining LightPAFF with complementary techniques like quantization and pruning, as well as scaling the framework to even larger "extra-large" models.

Summary updated

BibTeX
@misc{song2020lightpaff,
  author = {Kaitao Song and Hao Sun and Xu Tan and Tao Qin and Jianfeng Lu and Hongzhi Liu and Tie-Yan Liu},
  title = {{LightPAFF: A Two-Stage Distillation Framework for Pre-training and Fine-tuning}},
  year = {2020},
  eprint = {2004.12817},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2004.12817},
}
Figure