Gradient-based Intra-attention Pruning on Pre-trained Language Models

Ziqing Yang, Yiming Cui, Xin Yao, Shijin Wang
12/15/2022
cs.CL
transformer-attentiondistillation

Official code: airaria/GRAIN (18 stars, Python, Apache-2.0, last commit 2023-07-12).

Abstract

Pre-trained language models achieve superior performance but are computationally expensive. Techniques such as pruning and knowledge distillation have been developed to reduce their sizes and latencies.

Show full abstract

In this work, we propose a structured pruning method GRAIN (Gradient-based Intra-attention pruning), which performs task-specific pruning with knowledge distillation and yields highly effective models. Different from common approaches that prune each attention head as a whole, GRAIN inspects and prunes intra-attention structures, which greatly expands the structure search space and enables more flexible models. We also propose a gradient separation strategy that reduces the interference of distillation on pruning for a better combination of the two approaches. Experiments on GLUE, SQuAD, and CoNLL 2003 show that GRAIN notably outperforms other methods, especially in the high sparsity regime, and achieves $6\sim7\times$ speedups while maintaining $93\%\sim99\%$ performance. Under extreme compression where only $3\%$ transformer weights remain, the pruned model is still competitive compared to larger models.

View on arXivView PDF

Code Implementations(1)

airaria/GRAINOfficial100%
Apache-2.0

GRAIN: Gradient-based Intra-attention Pruning on Pre-trained Language Models

183Python, Jupyter NotebookMay 4, 20233 years agoApache-2.0

Similar Papers

Cite this paper

@article{yang2022gradientbased,
  title  = {Gradient-based Intra-attention Pruning on Pre-trained Language Models},
  author = {Ziqing Yang and Yiming Cui and Xin Yao and Shijin Wang},
  year   = {2022},
  eprint = {2212.07634},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2212.07634}
}

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/2212.07634.svg)](https://codeofpaper.com/paper/2212.07634)

Discussion