Skip to main content
QUICK REVIEW

[Paper Review] LightPAFF: A Two-Stage Distillation Framework for Pre-training and Fine-tuning

Kaitao Song, Hao Sun|arXiv (Cornell University)|Apr 27, 2020
Topic ModelingComputer Science17 references9 citations
TL;DR

LightPAFF is a two-stage knowledge distillation framework that transfers knowledge from large pre-trained models (e.g., BERT, GPT-2, MASS) to smaller student models during both pre-training and fine-tuning, achieving comparable performance with up to 5× smaller model size and 5–7× faster inference speed, enabling efficient deployment on resource-constrained systems.

ABSTRACT

While pre-training and fine-tuning, e.g., BERT~\citep{devlin2018bert}, GPT-2~\citep{radford2019language}, have achieved great success in language understanding and generation tasks, the pre-trained models are usually too big for online deployment in terms of both memory cost and inference speed, which hinders them from practical online usage. In this paper, we propose LightPAFF, a Lightweight Pre-training And Fine-tuning Framework that leverages two-stage knowledge distillation to transfer knowledge from a big teacher model to a lightweight student model in both pre-training and fine-tuning stages. In this way the lightweight model can achieve similar accuracy as the big teacher model, but with much fewer parameters and thus faster online inference speed. LightPAFF can support different pre-training methods (such as BERT, GPT-2 and MASS~\citep{song2019mass}) and be applied to many downstream tasks. Experiments on three language understanding tasks, three language modeling tasks and three sequence to sequence generation tasks demonstrate that while achieving similar accuracy with the big BERT, GPT-2 and MASS models, LightPAFF reduces the model size by nearly 5x and improves online inference speed by 5x-7x.

Motivation & Objective

  • Address the challenge of deploying large pre-trained models (e.g., BERT, GPT-2) in online or mobile settings due to high memory and latency costs.
  • Overcome the limitations of prior knowledge distillation methods that only compress models in the fine-tuning stage, leading to significant accuracy drops.
  • Develop a unified framework applicable to diverse pre-training objectives—masked language modeling (BERT), causal language modeling (GPT-2), and masked sequence-to-sequence modeling (MASS)—to ensure broad applicability.
  • Preserve general language understanding and generation capabilities in lightweight models by leveraging knowledge from both pre-trained and fine-tuned teacher models.
  • Enable efficient, low-latency inference without sacrificing performance across multiple NLP tasks, including classification, language modeling, and sequence-to-sequence generation.

Proposed method

  • Apply knowledge distillation in two distinct stages: first during pre-training using the pre-training dataset, and second during fine-tuning using task-specific data.
  • Use a student model with fewer parameters than the teacher model, trained to mimic both the logits and hidden representations of the teacher model in both stages.
  • Introduce a hyperparameter λ to balance knowledge distillation loss and standard cross-entropy loss from ground-truth labels during training.
  • Apply parameter-wise knowledge distillation by minimizing the L2 distance between student and teacher model parameters, with added Gaussian noise to improve robustness.
  • Formulate the distillation objective uniformly across BERT, GPT-2, and MASS, enabling consistent application across different pre-training objectives and model architectures.
  • Use a two-stage pipeline: (1) pre-train the teacher model, (2) fine-tune the teacher on a downstream task, (3) distill the pre-trained teacher to create a lightweight pre-trained student, and (4) fine-tune the student on the downstream task with distillation.

Experimental results

Research questions

  • RQ1Can knowledge distillation applied in both pre-training and fine-tuning stages significantly reduce model size and inference latency while preserving performance?
  • RQ2How does two-stage distillation compare to single-stage distillation (only in fine-tuning) in terms of accuracy and robustness for lightweight models?
  • RQ3Does the difficulty of the pre-training task (e.g., masked vs. causal language modeling) affect the optimal distillation hyperparameters and model performance?
  • RQ4Can the proposed LightPAFF framework be uniformly applied across diverse pre-trained models such as BERT, GPT-2, and MASS with different pre-training objectives?
  • RQ5To what extent does distillation in both stages improve generalization and robustness compared to distillation only in fine-tuning?

Key findings

  • LightPAFF reduces the model size of BERT, GPT-2, and MASS by nearly 5× while maintaining performance comparable to the original large models.
  • The framework improves online inference speed by 5× to 7× across all evaluated models, enabling practical deployment on edge devices.
  • Experiments on 9 downstream tasks—3 each for language understanding (SST-2, QQP, polyphone disambiguation), language modeling (WikiText-2, PTB, WikiText-103), and sequence-to-sequence generation (WMT Zh-En, En-De, En-Fr)—show consistent performance gains with compressed models.
  • The two-stage distillation approach leads to better generalization, as shown by improved robustness to parameter perturbations and stable performance across pre-training and fine-tuning stages.
  • The optimal distillation hyperparameter λ varies by model: λ = 1.0 for BERT, 0.7 for MASS, and 0.4 for GPT-2, reflecting differences in pre-training task difficulty and information retention.
  • The pre-training task difficulty correlates with performance: BERT (85% input tokens seen on average) is easiest, followed by MASS (75%), and GPT-2 (50%), which aligns with the observed accuracy drop in masked prediction tasks.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.