Contrastive Distillation on Intermediate Representations for Language Model Compression

Siqi Sun, Zhe Gan, Yu Cheng, Yuwei Fang, Shuohang Wang +1 more
9/29/2020
cs.CLcs.LG
distillationquantization-pruning

Official code: intersun/CoDIR (41 stars, Python, MIT, last commit 2022-10-04).

Abstract

Existing language model compression methods mostly use a simple L2 loss to distill knowledge in the intermediate representations of a large BERT model to a smaller one. Although widely used, this objective by design assumes that all the dimensions of hidden representations are independent, failing to capture important structural knowledge in the intermediate layers of the teacher network.

Show full abstract

To achieve better distillation efficacy, we propose Contrastive Distillation on Intermediate Representations (CoDIR), a principled knowledge distillation framework where the student is trained to distill knowledge through intermediate layers of the teacher via a contrastive objective. By learning to distinguish positive sample from a large set of negative samples, CoDIR facilitates the student's exploitation of rich information in teacher's hidden layers. CoDIR can be readily applied to compress large-scale language models in both pre-training and finetuning stages, and achieves superb performance on the GLUE benchmark, outperforming state-of-the-art compression methods.

View on arXivView PDF

Code Implementations(1)

intersun/CoDIROfficial100%
MIT

Code for EMNLP 2020 paper CoDIR

418Python, Jupyter NotebookSep 20, 20204 years agoMIT

Similar Papers

Cite this paper

@article{sun2020contrastive,
  title  = {Contrastive Distillation on Intermediate Representations for Language Model Compression},
  author = {Siqi Sun and Zhe Gan and Yu Cheng and Yuwei Fang and Shuohang Wang and Jingjing Liu},
  year   = {2020},
  eprint = {2009.14167},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2009.14167}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2009.14167.svg)](https://codeofpaper.com/paper/2009.14167)

Discussion