Abstract
Given a large Transformer model, how can we obtain a small and computationally efficient model which maintains the performance of the original model? Transformer has shown significant performance improvements for many NLP tasks in recent years. However, their large size, expensive computational cost, and long inference time make it challenging to deploy them to resource-constrained devices. Existing Transformer compression methods mainly focus on reducing the size of the encoder ignoring the fact that the decoder takes the major portion of the long inference time. In this paper, we propose PET (Parameter-Efficient knowledge distillation on Transformer), an efficient Transformer compression method that reduces the size of both the encoder and decoder. In PET, we identify and exploit pairs of parameter groups for efficient weight sharing, and employ a warm-up process using a simplified task to increase the gain through Knowledge Distillation. Extensive experiments on five real-world datasets show that PET outperforms existing methods in machine translation tasks. Specifically, on the IWSLT'14 EN→DE task, PET reduces the memory usage by 81.20% and accelerates the inference speed by 45.15% compared to the uncompressed model, with a minor decrease in BLEU score of 0.27.
Introduction
While Transformer models have revolutionized Natural Language Processing (NLP), their massive size makes them difficult to deploy on mobile or edge devices. Most existing compression research focuses on encoders (like BERT), but in sequence-to-sequence tasks like machine translation, the decoder is the primary bottleneck. Because decoders generate text one token at a time (auto-regressively), they account for the majority of inference time. PET (Parameter-Efficient knowledge distillation on Transformer) addresses this by compressing the entire Transformer pipeline—both encoder and decoder—without sacrificing the performance of large, pre-trained teacher models.
Methodology
Replaceable Pairs: Strategic Weight Sharing
Instead of simply removing layers, PET identifies specific modules that can share parameters without hurting performance. The authors found that the encoder and decoder have different sensitivities to weight sharing. In the encoder, sharing Query and Key matrices across different layers can actually improve performance by reducing redundancy.
In the decoder, which is more sensitive, PET shares the Query matrices between the self-attention sub-layer and the encoder-decoder attention sub-layer. This is effective because both sub-layers process the decoder's internal states.
Simplified Task Warm-up
Training a small "student" model to mimic a large "teacher" model is challenging when the student must immediately learn a massive vocabulary. PET introduces a "warm-up" phase where the student first learns a 4-class classification task based on the teacher's confidence (e.g., is the teacher confidently correct or unsure?).
To facilitate this, the authors developed an Architecture-Preserving Mapping. This mathematical approach maps the student's full-vocabulary output probabilities into these four confidence classes without adding extra layers, ensuring a smooth transition to the real translation task.
Experimental Results
PET was evaluated on five real-world translation benchmarks, including IWSLT’14, IWSLT’17, and WMT’17. It consistently outperformed state-of-the-art competitors like Patient-KD and CAN.
- Efficiency: On the IWSLT’14 EN→DE task, PET reduced memory usage by 81.20% and accelerated inference by 45.15%.
- Quality: The decrease in BLEU score was only 0.27 points, making the compression virtually imperceptible in terms of translation quality.
- Robustness: PET demonstrated higher stability across different beam sizes compared to other compressed models, which often become erratic during text generation.
Key Insights and Future Work
The success of PET highlights that the decoder is much more "fragile" than the encoder and requires more careful optimization. Furthermore, the warm-up task suggests that student models benefit from learning the teacher's behavior and uncertainty before mastering the final task.
Future work aims to extend PET to optimize embedding layers and feed-forward networks (FFNs) more effectively. The authors also plan to incorporate intermediate distillation (mimicking internal attention maps) and scale the framework to extremely large models like GPT-3.
Summary updated