ERNIE 3.0 Tiny: Frustratingly Simple Method to Improve Task-Agnostic Distillation Generalization

Weixin Liu, Xuyi Chen, Jiaxiang Liu, Shikun Feng, Yu Sun, Hao Tian, Hua WuarXiv 2023

TL;DR

This paper introduces Multi-task Infused Task-agnostic Knowledge Distillation (MITKD), a novel method to improve the generalization of smaller, distilled language models. By first training a "teacher" model on multiple tasks and then distilling its knowledge, MITKD significantly boosts the student model's performance across various domains, outperforming existing methods and even a much larger BERT model.

What Problem Does This Paper Address?

Deploying large, state-of-the-art pre-trained language models (PLMs) in real-world applications is challenging due to their computational demands. Knowledge distillation (KD) offers a solution by compressing these large models into smaller, more efficient "student" models. While task-specific KD excels at transferring knowledge for a particular task, it requires separate distillation for each new task. Task-agnostic KD aims for a "one-shot" distillation, producing a student model that can be fine-tuned on any downstream task. However, existing task-agnostic methods often suffer from a "generalization gap," meaning the distilled student model doesn't perform as well as the teacher on unseen tasks or domains. This paper addresses this gap by proposing a method to improve the generalization capabilities of task-agnostic distilled models.

Methods

The core innovation is Multi-task Infused Task-agnostic Knowledge Distillation (MITKD). This method involves a two-stage process:

  1. Multi-task Teacher Enhancement: The large "teacher" PLM is first fine-tuned on a diverse set of downstream tasks simultaneously using Multi-Task Learning (MTL). This MTL stage helps the teacher model learn a more generalizable representation.
  2. Task-Agnostic Distillation: The MTL-enhanced teacher model is then used to distill knowledge into a smaller "student" model using a standard task-agnostic distillation technique. The paper leverages MiniLMv2 as the distillation method, which focuses on mimicking the self-attention mechanisms between teacher and student.

This approach aims to infuse the generalizable knowledge acquired during MTL into the task-agnostic distillation process, thereby improving the student's ability to adapt to new tasks and domains.

Datasets

The paper utilizes a variety of datasets for both training and evaluation:

  • MTL Fine-tuning (Teacher Enhancement): The teacher model is fine-tuned on approximately 50 downstream tasks (listed in Appendix A.4).
  • Task-Agnostic Distillation: The distillation process itself uses the pre-training data of the teacher model (e.g., RoBERTa's pre-training data).
  • Evaluation:
    • In-domain: GLUE benchmark and SQuAD 2.0.
  • Out-domain: A diverse set of nine datasets across seven domains, including CHEMPROT (biology), ANLI (general), ACL-ARC and SCIERC (computer science), PARTISAN (news), HELPFUL (review), SCOTUS and LEDGAR (law), and FinBank (finance).
  • Low-resource: Datasets from various domains with varying training data sizes (1%, 10%, 50%).
  • Chinese Datasets: For experiments with ERNIE 3.0, a suite of 10 Chinese datasets for classification, out-domain, and low-resource tasks were used.

Key Insights and Ideas

  • MTL is Key to Generalization: The paper strongly suggests that the generalization capabilities learned by a teacher model through Multi-Task Learning can be effectively transferred to a smaller student model via task-agnostic distillation. This is a crucial insight, as it shows how to imbue distilled models with broader applicability beyond their direct training tasks.
  • Beyond Larger Teachers: The research highlights that simply using a larger teacher model isn't the only path to better student performance. Enhancing the teacher's knowledge through methods like MTL can be equally, if not more, impactful, especially when considering the size gap between student and teacher.
  • Task-Agnostic Distillation Can Be "Smart": By infusing task knowledge (via MTL) into the task-agnostic distillation framework, the authors demonstrate that it's possible to achieve the benefits of both task-specific (high performance) and task-agnostic (easy deployment) distillation.

Key Results

  • Out-domain Performance: MITKD significantly outperforms baselines like MiniLMv2-B (vanilla task-agnostic) by 3.9 average points on out-domain tasks. It even surpasses MiniLMv2-L (distilled from a larger teacher without MTL) by 2.6 points.
  • In-domain Performance: MITKD achieves state-of-the-art results on most GLUE and SQuAD 2.0 tasks, outperforming baselines by 1.2 points.
  • Efficiency and Performance: The MITKD-produced student model (ERNIE 3.0 Tiny) is 5.3x faster than BERT$_{\text{Base}}$ while achieving comparable or better performance on four GLUE tasks and SQuAD 2.0.
  • Chinese Datasets: Applying MITKD to ERNIE 3.0 results in ERNIE 3.0 Tiny, which achieves state-of-the-art results on 10 Chinese datasets, outperforming the Chinese version of TinyBERT by 4.3 average points.
  • Low-Resource Performance: MITKD consistently outperforms other baselines on low-resource tasks, demonstrating its robustness across different data scales.

Limitations and Future Work

  • Computational Overhead: The primary limitation acknowledged is the additional multi-task finetuning stage for the teacher model, which requires extra computational resources compared to vanilla task-agnostic distillation.
  • Future Work: The paper implicitly suggests exploring more sophisticated MTL strategies or different distillation techniques to further enhance generalization. The success on Chinese datasets also opens avenues for applying MITKD to other languages and multilingual models.

Summary updated

Abstract

Task-agnostic knowledge distillation attempts to address the problem of deploying large pretrained language model in resource-constrained scenarios by compressing a large pretrained model called teacher into a smaller one called student such that the student can be directly finetuned on downstream tasks and retains comparable performance. However, we empirically find that there is a generalization gap between the student and the teacher in existing methods. In this work, we show that we can leverage multi-task learning in task-agnostic distillation to advance the generalization of the resulted student. In particular, we propose Multi-task Infused Task-agnostic Knowledge Distillation (MITKD). We first enhance the teacher by multi-task training it on multiple downstream tasks and then perform distillation to produce the student. Experimental results demonstrate that our method yields a student with much better generalization, significantly outperforms existing baselines, and establishes a new state-of-the-art result on in-domain, out-domain, and low-resource datasets in the setting of task-agnostic distillation. Moreover, our method even exceeds an 8x larger BERT$_{\text{Base}}$ on SQuAD and four GLUE tasks. In addition, by combining ERNIE 3.0, our method achieves state-of-the-art results on 10 Chinese datasets.
BibTeX
@misc{liu2023ernie,
  author = {Weixin Liu and Xuyi Chen and Jiaxiang Liu and Shikun Feng and Yu Sun and Hao Tian and Hua Wu},
  title = {{ERNIE 3.0 Tiny: Frustratingly Simple Method to Improve Task-Agnostic Distillation Generalization}},
  year = {2023},
  eprint = {2301.03416},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2301.03416},
}
Figure