Differentiable Subset Pruning of Transformer Heads

Jiaoda Li, Ryan Cotterell, Mrinmaya Sachan
8/10/2021
72 citations
cs.CL
transformer-attention

Official code: rycolab/differentiable-subset-pruning (17 stars, Python, last commit 2021-08-20).

Abstract

Multi-head attention, a collection of several attention mechanisms that independently attend to different parts of the input, is the key ingredient in the Transformer. Recent work has shown, however, that a large proportion of the heads in a Transformer's multi-head attention mechanism can be safely pruned away without significantly harming the performance of the model; such pruning leads to models that are noticeably smaller and faster in practice.

Show full abstract

Our work introduces a new head pruning technique that we term differentiable subset pruning. Intuitively, our method learns per-head importance variables and then enforces a user-specified hard constraint on the number of unpruned heads. The importance variables are learned via stochastic gradient descent. We conduct experiments on natural language inference and machine translation; we show that differentiable subset pruning performs comparably or better than previous works while offering precise control of the sparsity level.

View on arXivView PDF

Code Implementations(1)

172Python, Jupyter NotebookAug 6, 20215 years ago

Similar Papers

Cite this paper

@article{li2021differentiable,
  title  = {Differentiable Subset Pruning of Transformer Heads},
  author = {Jiaoda Li and Ryan Cotterell and Mrinmaya Sachan},
  year   = {2021},
  eprint = {2108.04657},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2108.04657}
}

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

Discussion