Rethinking Task-Specific Knowledge Distillation: Contextualized Corpus as Better Textbook

Chang Liu, Chongyang Tao, Jianxin Liang, Tao Shen, Jiazhan Feng, Quzhe Huang, Dongyan Zhao

Introduction

Knowledge Distillation (KD) has become the cornerstone of deploying large-scale Pre-trained Language Models (PLMs) in resource-constrained environments. By transferring knowledge from a large "teacher" model to a smaller "student," researchers can maintain high performance with significantly lower computational overhead. However, the effectiveness of KD is heavily dependent on the data used during the distillation process—the "textbook" from which the student learns. This paper introduces the Contextualized Corpus (CC), a novel approach to constructing task-specific training data that bridges the gap between general-purpose pre-training and narrow task fine-tuning.

The Limitations of Traditional Knowledge Distillation

The standard KD paradigm typically involves two distinct stages:

  1. General Distillation: The student model mimics the teacher on a massive, task-agnostic corpus (e.g., Wikipedia or BookCorpus).
  2. Task-Specific Distillation: The student is fine-tuned on a specific, labeled dataset (e.g., sentiment analysis or natural language inference).

The authors identify a fundamental mismatch in this approach. General distillation often provides an overwhelming amount of irrelevant information for a small student model with limited parameter capacity. Conversely, task-specific datasets are frequently too small and narrow, leading to rapid overfitting before the student can fully internalize the teacher's nuanced expertise. The goal is to find a "Goldilocks" corpus: one that possesses the linguistic diversity of a general corpus but remains strictly relevant to the target task.

The Contextualized Corpus (CC) Framework

The core innovation of this work is the automated construction of a custom "textbook" for every downstream task. The process involves three main steps:

  1. Anchor-Based Retrieval: Every sentence in the original task dataset is treated as an "anchor."
  2. Relevance-Based Retrieval: Using the BM25 algorithm, the system searches a massive 160GB general corpus (the RoBERTa pre-training data) to identify the top-$k$ most relevant sentences for each anchor.
  3. Deduplication: These retrieved sentences are merged and deduplicated to form the Contextualized Corpus.
Overview of the Contextualized Corpus (CC) distillation framework, illustrating the three-step process from initialization to task adaptation.

The distillation framework then proceeds through initialization (either random or pre-distilled), knowledge injection using the CC, and final task adaptation on labeled data.

Experimental Evaluation

The researchers evaluated the CC method across the GLUE (General Language Understanding Evaluation) benchmark, covering both single-sentence tasks (like SST-2 and CoLA) and sentence-pair tasks (like MNLI and RTE). They compared CC against two standard baselines: WikiBook (a general corpus) and TaskDA (task data augmented with contextual word replacement).

Key Findings

The experiments yielded several significant insights into the nature of task-specific distillation:

  • Superior Performance and Efficiency: CC consistently outperformed both WikiBook and TaskDA. The gains were particularly pronounced in low-resource settings. For instance, on the RTE task, a randomly initialized student using CC achieved a score of 82.3, a massive improvement over the 59.9 achieved with standard TaskDA.
  • Redefining Initialization: Perhaps the most striking result is that CC allows student models to be trained from scratch (random initialization) while still matching or exceeding the performance of models that underwent expensive general pre-distillation. This suggests that a high-quality, task-relevant "textbook" can compensate for the lack of a general-purpose starting point.
  • The Scale-Relevance Trade-off: While increasing the size of the CC (by increasing the number of retrieved sentences $k$) generally improves performance, there is a point of diminishing returns. The data must remain highly relevant to the target task to be effective.
Accuracy trends across various GLUE tasks (MNLI, SST-2, CoLA, RTE) as training steps increase, showing the impact of different data retrieval densities.

Conclusion

By rethinking the "textbook" used for knowledge distillation, this paper demonstrates that relevance and diversity are not mutually exclusive. The Contextualized Corpus provides a scalable, automated way to create high-quality training data that maximizes the potential of small student models. This approach not only improves performance across standard benchmarks but also offers a more flexible and efficient path for customizing models to specific hardware and task constraints.

Summary updated

BibTeX
@inproceedings{liu2022rethinking,
  author = {Chang Liu and Chongyang Tao and Jianxin Liang and Tao Shen and Jiazhan Feng and Quzhe Huang and Dongyan Zhao},
  title = {{Rethinking Task-Specific Knowledge Distillation: Contextualized Corpus as Better Textbook}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.emnlp-main.729},
}
Figure