Distilling Linguistic Context for Language Model Compression

Geondo Park, Gyeongman Kim, Eunho Yang

Introduction

Large-scale Transformer models like BERT and GPT have set new benchmarks in Natural Language Processing (NLP). However, their massive parameter counts make them computationally expensive and difficult to deploy on resource-constrained devices. Knowledge Distillation (KD) has emerged as a primary technique to compress these "obese" models into smaller, faster "student" versions. Researchers from KAIST and AITRICS have introduced Contextual Knowledge Distillation (CKD), a novel framework that moves beyond simple output matching to transfer the underlying linguistic intuition of teacher models.

The Challenge of Model Compression

Traditional KD methods often suffer from two significant limitations. First, they typically treat word representations as independent entities, failing to capture the complex semantic and syntactic relationships between words that a teacher model has mastered. Second, many state-of-the-art distillation techniques impose strict architectural constraints, requiring the student model to mirror the teacher's internal structure (e.g., matching the number of layers or hidden dimensions). This "architectural handcuffing" limits the flexibility needed to optimize student models for specific hardware.

Contextual Knowledge Distillation (CKD)

The proposed CKD framework addresses these issues by focusing on the structural knowledge of the teacher model through two primary components: Word Relation (WR) and Layer Transforming Relation (LTR).

Overview of the CKD framework, illustrating (a) the general distillation architecture and (b) the specific Word Relation (WR) and Layer Transforming Relation (LTR) modules.

Word Relation (WR): Capturing Horizontal Context

CKD-WR focuses on the relationships between words within a single layer. Unlike previous methods that only consider pair-wise distances, CKD utilizes triple-wise relationships (angles) to capture higher-order geometric structures in the embedding space. This allows the student to replicate the "geometry" of how the teacher perceives word interactions. To maintain computational efficiency, the authors implement a "locality" constraint, focusing on word triples within a local window, reducing complexity from $O(n^3)$ to $O(\delta^2 n)$.

Layer Transforming Relation (LTR): Capturing Vertical Context

CKD-LTR tracks how a word's representation evolves as it passes through the model's layers. By matching these transformation patterns, the student learns the hierarchical logic the teacher uses to process information. Because CKD matches the statistics of these relationships rather than raw vector values, it is entirely architecture-agnostic, allowing for distillation between models with different layer counts or hidden sizes.

Experimental Results

The researchers evaluated CKD on the GLUE benchmark and the SQuAD 1.1 dataset. The results demonstrate that CKD consistently outperforms existing state-of-the-art distillation methods like TinyBERT and PKD.

Comparison of Accuracy (%) on the SST-2 task across various student model configurations (layers/hidden units). CKD consistently outperforms LogitKD, TinyBERT, and MiniLM.

On the CoLA task, which measures linguistic acceptability, CKD achieved a score of 55.1, surpassing TinyBERT's 53.8. In reading comprehension (SQuAD 1.1), CKD reached an F1 score of 88.7, effectively matching the performance of the much larger teacher model (88.6). Furthermore, as shown in the figure above, CKD maintains a performance edge across a wide variety of student model sizes, proving its robustness and scalability.

Conclusion and Future Work

Contextual Knowledge Distillation represents a shift in model compression, prioritizing the transfer of relational "logic" over raw data values. By capturing both horizontal word relations and vertical layer transformations, CKD provides a flexible, high-performance path for deploying advanced NLP models on edge devices. Future research may explore more complex relationship definitions or extend the framework to other architectures, such as Vision Transformers.

Summary updated

BibTeX
@inproceedings{park2021distilling,
  author = {Geondo Park and Gyeongman Kim and Eunho Yang},
  title = {{Distilling Linguistic Context for Language Model Compression}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  url = {https://openreview.net/forum?id=XXtDYnzNXCD},
}
Figure