Multi-Grained Knowledge Distillation for Named Entity Recognition

Xuan Zhou, Xiao Zhang, Chenyang Tao, Junya Chen, Bing Xu, Wei Wang, Jing XiaoNAACL 2021

Abstract

Named Entity Recognition (NER) is a critical sequence labeling task often dominated by large-scale pre-trained models like BERT. However, the computational intensity of these models limits their deployment in resource-constrained environments. This paper introduces a multi-grained knowledge distillation (KD) framework that compresses massive BERT-based teachers into lightweight BiLSTM-CRF students. By leveraging the $k$-best Viterbi algorithm to generate surrogate labels and employing a combination of fine-grained and coarse-grained losses, the proposed method achieves performance comparable to state-of-the-art models while providing a 40x speedup and significant memory savings.

Introduction

The primary challenge in distilling knowledge for NER lies in its nature as a sequence labeling task. Unlike simple classification, NER involves exponential complexity in label combinations ($T^L$ for a sentence of length $L$ with $T$ tags) and strict structural dependencies between labels. Standard KD techniques often fail to capture these structural "rules" or the full probability distribution of sequences. This work addresses these hurdles by focusing on the most probable sequences and accounting for teacher uncertainty through a multi-grained approach.

Methodology

The proposed framework bridges the gap between a heavy teacher (e.g., BERT) and a light student (e.g., BiLSTM-CRF) through several key components:

Overview of the multi-grained knowledge distillation framework, showing the teacher-student pipeline and loss calculation.
  1. $k$-best Viterbi Surrogate Labels: To manage exponential complexity, the Viterbi algorithm identifies the top $K$ most likely sequences from the teacher, which serve as soft labels for the student.
  2. Multi-Grained Distillation:
  3. Fine-grained: The student is trained to match the teacher's specific probability for each of the top $K$ sequences.
  4. Coarse-grained (Fuzzy): To account for teacher uncertainty, the top $K$ sequences are grouped into a single "fuzzy" set. The student learns the collective probability of these top-tier candidates versus the "noise" of unlikely ones.
  5. Automated Loss Weighting: Rather than manual tuning, the model uses an uncertainty weighting strategy to learn the optimal balance between hard labels and soft labels during training.
  6. Data Augmentation: The framework leverages unlabeled data by having the teacher generate surrogate labels, providing additional training examples for the student.

Key Insights and Results

A core finding of this research is that the "long tail" of probability matters. Even after selecting the top $K$ sequences, the remaining "non-top-K" sequences still hold significant probability mass. The proposed loss functions explicitly account for this residual probability rather than discarding it.

Illustration of how teacher outputs are partitioned into Top-K and Non-top-K sets to compute fine-grained and coarse-grained (fuzzy) losses.

Experimental results across five diverse benchmarks (English and Chinese) demonstrate the framework's robustness:

  • Efficiency: The BiLSTM-CRF student achieves a 40x reduction in parameters and a 40x speedup in inference time compared to the BERT-based teacher.
  • Accuracy: On the CoNLL-2003 dataset, the student reached an F1 score of 91.17, closely trailing the teacher's 92.03 and significantly outperforming a vanilla BiLSTM-CRF (80.08).
  • Data Synergy: On the Weibo dataset, which has limited labeled data, adding unlabeled data via the teacher's surrogate labels boosted the student's F1 score from 57.14 to 71.62, occasionally surpassing the teacher's performance.

Conclusion

Multi-grained knowledge distillation provides a powerful path for deploying high-performance NER models on edge devices. While the method is sensitive to the hyperparameter $K$, it consistently outperforms standard token-level distillation across various domains. Future work may explore broader student architectures and applications to other sequence tasks like speech recognition.

Summary updated

BibTeX
@inproceedings{zhou2021multi,
  author = {Xuan Zhou and Xiao Zhang and Chenyang Tao and Junya Chen and Bing Xu and Wei Wang and Jing Xiao},
  title = {{Multi-Grained Knowledge Distillation for Named Entity Recognition}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.naacl-main.454},
}
Figure