ERNIE-Tiny Progressive Compression
- The paper demonstrates that a four-stage progressive distillation approach effectively compresses large PLMs into compact student models with over 98% accuracy retention.
- It employs a systematic transition through general distillation, general-enhanced, task-adaptive, and task-specific stages to smoothly bridge pretraining and finetuning regimes.
- The method achieves a 9.4× speedup and significant parameter reduction, outperforming comparable compact models on both English GLUE and Chinese NLP benchmarks.
ERNIE-Tiny Progressive Compression refers to a four-stage progressive distillation framework for compressing large pretrained LLMs (PLMs) such as BERT and ERNIE into significantly smaller, faster student models while maintaining high task performance. The core insight is to mitigate the commonly observed pretrain-finetune distillation discrepancy by gradually morphing the teacher model, training data, and learning objective from general, unsupervised pretraining conditions to task-specific, supervised finetuning conditions. At each of the four stages, only one component is changed, enabling smoother student optimization and minimizing performance degradation. Empirical results demonstrate that ERNIE-Tiny achieves state-of-the-art performance among compact models on English (GLUE) and Chinese NLP tasks, with over 9× inference speedup and substantial parameter reduction (Su et al., 2021).
1. Motivation and Problem Setting
PLMs such as BERT<sub>base</sub> (12 layers, 768-d hidden state, 109M parameters) achieve state-of-the-art performance across numerous NLP tasks. However, their large parameter counts and high inference latencies preclude deployment on resource-constrained environments such as CPU servers and edge devices. Knowledge distillation (KD) is a standard approach for compressing PLMs; it involves training a small student to mimic a larger teacher, typically using latent (feature-based) and/or soft-label (probabilistic output) matching.
Conventional KD techniques for PLMs either perform distillation only during pretraining or only during finetuning, or else transition abruptly from a general pretraining regime to a specific finetuning regime. This abrupt change across teacher model, data distribution, and objective introduces an optimization gap and can hinder student adaptation. ERNIE-Tiny addresses this problem by defining a curriculum-inspired progressive distillation sequence, in which each transition modifies only one component, thus enabling smoother optimization and improved generalization, especially in low-resource or out-of-domain settings (Su et al., 2021).
2. Progressive Distillation Framework
The ERNIE-Tiny framework consists of four stages—General Distillation (GD), General-Enhanced Distillation (GED), Task-Adaptive Distillation (TAD), and Task-Specific Distillation (TSD)—and systematically transitions through variations in teacher, data, and loss.
Notation
| Symbol | Meaning |
|---|---|
| , | Pretrained, finetuned teacher models |
| Student model | |
| , | General (unlabeled), task (labeled) data |
| , | Teacher/student hidden states at layer |
| , | Attention probabilities |
| , | Projection operators for alignment |
| , | Logits |
| Ground-truth label | |
| Loss weighting hyperparameters |
The Four Distillation Stages
- General Distillation (GD)
- Teacher: Pretrained PLM ()
- Data: General, unlabeled corpus (, e.g., Wikipedia + BookCorpus)
- Loss: Latent distillation. The student matches selected teacher hidden states and attention distributions over general data:
where .
- General-Enhanced Distillation (GED)
- Teacher: Finetuned teacher (), trained on
- Data: Still
- Loss: Latent distillation
- Significance: Only the teacher changes; allows injection of task-specific knowledge into student representations over large, general corpora, enhancing robustness.
- Task-Adaptive Distillation (TAD)
- Teacher:
- Data: Switch to labeled task-specific data ()
- Loss: Latent distillation
- Significance: Only the data changes; prepares the student for supervised objectives without abrupt introduction of classification loss.
- Task-Specific Distillation (TSD)
- Teacher:
- Data:
- Loss: Combined latent distillation, soft-label KD, and hard-label cross-entropy:
where
Typically , .
Component Transitions Table
| Stage Transition | What Changes |
|---|---|
| GD → GED | Teacher () |
| GED → TAD | Data () |
| TAD → TSD | Loss (latent→latent+soft+hard) |
3. Training Procedure and Hyperparameters
A pseudocode encapsulation of the procedure:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
for step in 1...N1: x = sample(D_g) L_lat = latent_loss(x; teacher=T_g, student=S) S.params -= η1 * ∇L_lat for step in 1...N2: x = sample(D_g) L_lat = latent_loss(x; teacher=T_f, student=S) S.params -= η2 * ∇L_lat for epoch in 1...E3: for (x, y) in batches(D_t): L_lat = latent_loss(x; teacher=T_f, student=S) S.params -= η3 * ∇L_lat for epoch in 1...E4: for (x, y) in batches(D_t): L_lat = latent_loss(x; teacher=T_f, student=S) L_soft = soft_loss(x; teacher=T_f, student=S) L_hard = hard_loss(y, student_logits(x)) L_TSD = β * L_lat + α * L_soft + (1−α) * L_hard S.params -= η4 * ∇L_TSD |
Model specification:
- Teacher : BERT<sub>base</sub> (12L, 768-d, FFN 3072, 109M params)
- Student : 4 layers, 312-d hidden, FFN 1200, 14.5M params
Data:
- : Wikipedia + BookCorpus
- (English): GLUE suite (MNLI, QQP, QNLI, SST-2, CoLA, RTE, MRPC, STS-B)
- (Chinese): XNLI, LCQMC, ChnSentiCorp, NLPCC-DBQA, MSRA-NER
Hyperparameters (for GLUE tasks; analogous for Chinese):
- GD & GED: batch 1280, lr , 500K steps, Adam, warmup 500, dropout 0.0
- TAD: batch 256/128, lr , 5–50 epochs, warmup 10%, dropout 0.0
- TSD: batch 256/128, lr / , 3 epochs, warmup 10%, 0.0 dropout
4. Empirical Results
English GLUE (test set, official GLUE server):
| Method | Params | Speedup | Avg. Score |
|---|---|---|---|
| BERT<sub>base</sub> | 109M | 1× | 79.6 |
| DistilBERT | 52M | 3× | 71.9 |
| BERT-PKD | 52M | 3× | 72.6 |
| BERT-EMD | 14.5M | 9.4× | 74.7 |
| TinyBERT | 14.5M | 9.4× | 77.0 |
| MobileBERT | 15.1M | 8.6× | 77.0 |
| ERNIE-Tiny | 14.5M | 9.4× | 78.0 |
ERNIE-Tiny retains over 98% of BERT<sub>base</sub>’s performance, surpassing prior 4-layer distillation SOTAs (TinyBERT, MobileBERT) by approximately +1% GLUE score (Su et al., 2021).
Chinese NLP Tasks (dev-set averages over 5 runs):
| Method | Params | Speedup | Avg. Accuracy |
|---|---|---|---|
| ERNIE2.0<sub>base</sub> | 109M | 1× | 88.4 |
| BERT<sub>base</sub> | 109M | 1× | 86.3 |
| TinyBERT (repro’d) | 14.5M | 9.4× | 85.3 |
| ERNIE-Tiny | 14.5M | 9.4× | 86.7 |
ERNIE-Tiny slightly exceeds the performance of the full 12-layer BERT<sub>base</sub> on Chinese suite tasks (by ≈ +0.4%), while being approximately 7.5× smaller and 9.4× faster.
Ablation Analysis
- Removing both GD & GED reduces average GLUE from 75.7→55.0 (for MRPC/CoLA/MNLI).
- Skipping GED (keeping teacher as through TAD) decreases performance by ≈ 3.3 points.
- Skipping TAD (immediate supervised loss in TSD) results in ≈ 4.1-point drop.
5. Mechanistic Analysis and Insights
Progressive component transition in ERNIE-Tiny contributes to its empirical effectiveness through several factors:
- Smoother optimization: Gradual introduction of teacher specialization, data specificity, and classification loss ensures the student is not destabilized by simultaneous abrupt shifts, leading to improved optimization trajectories and final accuracy.
- Task-knowledge augmentation through GED: Finetuned teacher guidance (on general data) exposes the student to task-specific features on a large corpus, reducing overfitting (when is small) and improving out-of-domain generalization (demonstrated by boosted performance on SNLI/RTE when distilled using MNLI).
- Adaptive bridging via TAD: Preceding classification loss with latent KD on labeled data enables the student to internalize teacher representations specific to the task, reducing loss shocks and enhancing adaptation.
6. Limitations and Future Directions
Key limitations are the increased training cost associated with four sequential distillation stages (∼2 days on 4× V100 GPUs for English GLUE), and reliance on access to large unlabeled corpora in GED (same as BERT pretraining data).
Potential research avenues include:
- Scaling GED with larger corpora (e.g., C4).
- Designing dynamic curricula where the number of GED/TAD iterations is task-adaptive.
- Jointly searching for optimal student architectures (e.g., via NAS) within the progressive distillation paradigm.
ERNIE-Tiny’s progressive distillation sequence demonstrates that carefully staged transitions in teacher, data, and loss are instrumental for attaining nearly teacher-level accuracy in highly compressed student architectures, setting new state-of-the-art results for 4-layer transformer-based PLMs on both English and Chinese language benchmarks (Su et al., 2021).