On the weak link between importance and prunability of attention heads (2020)

Abstract: Given the success of Transformer-based models, two directions of study have emerged: interpreting role of individual attention heads and down-sizing the models for efficiency. Our work straddles these two streams: We analyse the importance of basing pruning strategies on the interpreted role of the attention heads. We evaluate this on Transformer and BERT models on multiple NLP tasks. Firstly, we find that a large fraction of the attention heads can be randomly pruned with limited effect on accuracy. Secondly, for Transformers, we find no advantage in pruning attention heads identified to be important based on existing studies that relate importance to the location of a head. On the BERT model too we find no preference for top or bottom layers, though the latter are reported to have higher importance. However, strategies that avoid pruning middle layers and consecutive layers perform better. Finally, during fine-tuning the compensation for pruned attention heads is roughly equally distributed across the un-pruned heads. Our results thus suggest that interpretation of attention heads does not strongly inform pruning.

## introduction the acclaimed success of transformer-based models across nlp tasks has been followed by two important directions of research. in the first direction, interpretability studies aim to understand how these models work. given that multi-headed attention is an important feature of these models, researchers have focused on attention heads as the units of interpretation. these studies comment on the role of each attention head and the relation between a head's position and its significance @xcite @xcite @xcite . these studies show that certain heads are more important based on (i) their position in the network (top, middle, bottom), or (ii) the component to which they belong (encoder self-attention, decoder self-attention, encoder-decoder cross attention), or (iii) the functional role they play (e.g., syntactic/semantic). in the other major direction, these large transformer-based models have been down-sized to be more time and space efficient. different methods for down-sizing have been studied such as pruning @xcite @xcite , distillation @xcite @xcite , weight quantization @xcite , and weight factorization and parameter sharing @xcite . pruning techniques have been particularly successful in reinforcing the folk-lore that these models are highly over-parameterized. these pruning methods prune parameters based on magnitude @xcite , importance (mccarley, 2019) or layer-wise @xcite . in this paper, we straddle these two directions of work by asking the following question: can we randomly prune heads, thus completely ignoring any notion of importance of heads? to answer this, we systematically study the effect of randomly pruning specific subsets of attention heads on the accuracy on different tasks. across experiments, we modify the random sampling to vary the percentage of heads pruned and their location in the network (components and layers). we evaluate these experiments both on the transformer and bert models. our results show that a large fraction of attention heads can be pruned randomly: 75% of the attention heads of transformer can be randomly pruned with a drop of less than 1 bleu point on nmt tasks. similarly, half of the attention heads of bert can be randomly pruned with an average drop in accuracy of less than 1% across a chosen set of glue tasks foot_0 . significantly for transformers, we find no evidence for pruning methods preferring specific attention heads based on their location; even when the locations are chosen to match attention heads identified to be more important in existing studies. similarly on the bert model, pruning top and bottom layers do not show significant difference, even though existing studies attribute higher importance to the latter @xcite . however, we identify a preference to avoid pruning the middle layers and consecutive layers. lastly, we check if during fine-tuning certain heads compensate more for the pruned heads. if so, such heads would perhaps be more important. however, we find no such evidence. in particular, during fine-tuning, the un-pruned heads change similarly across most pruning configurations. overall, our experiments suggest that interpretation of attention heads does not strongly inform pruning. the rest of the paper is organized as follows: section 2 mentions about the models and the datasets used for this work followed by section 3 which provides details of the experimental process. this section reports results on both transformer and bert models. we summarize our work in section 4. ## conclusion we systematically studied the effect of pruning attention heads in transformer and bert models. we confirmed the general expectation that a large number of attention heads can be pruned with limited impact on performance. for transformers we observed no preference for pruning attention heads which have been identified as important in interpretability studies. similarly, for bert we found no preference between pruning top and bottom layers. however, pruning middle layers and consecutive layers led to a larger drop in accuracy. we also observe that the recovery during fine-tuning was uniformly distributed across attention heads. we conclude that there is often no direct entailment between importance of an attention head as characterised in several recent studies, and low prunability of the respective head using random pruning.