On Attention Redundancy: A Comprehensive Study

21801

Authors

nan

Abstract

AbstractMulti-layer multi-head self-attention mechanism is widely applied in modern neural language models. Attention redundancy has been observed among attention heads but has not been deeply studied in the literature. Using BERT-base model as an example, this paper provides a comprehensive study on attention redundancy which is helpful for model interpretation and model compression. We analyze the attention redundancy with Five-Ws and How. (What) We define and focus the study on redundancy matrices generated from pre-trained and fine-tuned BERT-base model for GLUE datasets. (How) We use both token-based and sentence-based distance functions to measure the redundancy. (Where) Clear and similar redundancy patterns (cluster structure) are observed among attention heads. (When) Redundancy patterns are similar in both pre-training and fine-tuning phases. (Who) We discover that redundancy patterns are task-agnostic. Similar redundancy patterns even exist for randomly generated token sequences. (“Why”) We also evaluate influences of the pre-training dropout ratios on attention redundancy. Based on the phase-independent and task-agnostic attention redundancy patterns, we propose a simple zero-shot pruning method as a case study. Experiments on fine-tuning GLUE tasks verify its effectiveness. The comprehensive analyses on attention redundancy make model understanding and zero-shot model pruning promising.

Keywords

nan

Full Content

Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 930–945 June 6–11, 2021. ©2021 Association for Computational Linguistics 930 On Attention Redundancy: A Comprehensive Study Yuchen Bian, Jiaji Huang, Xingyu Cai, Jiahong Yuan, Kenneth Church Baidu Research, Sunnyvale, CA, USA {yuchenbian,huangjiaji,xingyucai,jiahongyuan,kennethchurch}@baidu.com Abstract Multi-layer multi-head self-attention mecha- nism is widely applied in modern neural lan- guage models. Attention redundancy has been observed among attention heads but has not been deeply studied in the literature. Us- ing BERT-base model as an example, this pa- per provides a comprehensive study on atten- tion redundancy which is helpful for model interpretation and model compression. We analyze the attention redundancy with Five- Ws and How. (What) We define and focus the study on redundancy matrices generated from pre-trained and fine-tuned BERT-base model for GLUE datasets. (How) We use both token-based and sentence-based distance functions to measure the redundancy. (Where) Clear and similar redundancy patterns (clus- ter structure) are observed among attention heads. (When) Redundancy patterns are simi- lar in both pre-training and fine-tuning phases. (Who) We discover that redundancy patterns are task-agnostic. Similar redundancy pat- terns even exist for randomly generated to- ken sequences. (“Why”) We also evaluate in- fluences of the pre-training dropout ratios on attention redundancy. Based on the phase- independent and task-agnostic attention redun- dancy patterns, we propose a simple zero-shot pruning method as a case study. Experiments on fine-tuning GLUE tasks verify its effective- ness. The comprehensive analyses on atten- tion redundancy make model understanding and zero-shot model pruning promising. 1 Introduction Multi-layer multi-head self-attention architectures (Transformer (Vaswani et al., 2017)) are widely applied in modern language models, such as BERT (Devlin et al., 2019), RoBERTa (Liu et al., 2019), OpenAI GPT (Radford et al., 2018), GPT- 2 (Radford et al., 2019) and ERNIE2.0 (Sun et al., 2019), to name a few. Redundancy phenomenon is discovered among 0 12 24 36 48 60 72 84 96 108 120 132 144 Head index 0 12 24 36 48 60 72 84 96 108 120 132 144 Head index 1 2 3 4 5 6 7 8 9 10 11 12 Layer index 1 2 3 4 5 6 7 8 9 10 11 12 Layer index 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 Figure 1: Pair-wise Jensen-Shannon distance of atten- tion heads for the pre-trained BERT-base model (12- layer-12-head self-attention). Attention redundancy (cluster with small distances) exists in adjacent atten- tion heads and layers. attention heads. It demonstrates that many atten- tion heads generate very similar attention matrices (Clark et al., 2019; Kovaleva et al., 2019). We take the pre-trained BERT-base model as an example. It learns 12-layer-12-head self-attention matrices de- scribing dependencies between each pair of tokens in a sentence. Then for each token, there are 144 attention vectors. We use Jensen-Shannon distance to measure the relationship between each pair of vectors. Then for one sentence (consisting of a sequence of tokens), the token-averaged distance …

Content truncated to 500 words

Labeled Text

AbstractMulti-layer multi-head self-attention mechanism is widely applied in modern neural language models. Attention redundancy has been observed among attention heads but has not been deeply studied in the literature. Using BERT-base model as an example, this paper provides a comprehensive study on attention redundancy which is helpful for model interpretation and model compression. We analyze the attention redundancy with Five-Ws and How. (What) We define and focus the study on redundancy matrices generated from pre-trained and fine-tuned BERT-base model for GLUE datasets. (How) We use both token-based and sentence-based distance functions to measure the redundancy. (Where) Clear and similar redundancy patterns (cluster structure) are observed among attention heads. (When) Redundancy patterns are similar in both pre-training and fine-tuning phases. (Who) We discover that redundancy patterns are task-agnostic. Similar redundancy patterns even exist for randomly generated token sequences. (“Why”) We also evaluate influences of the pre-training dropout ratios on attention redundancy. Based on the phase-independent and task-agnostic attention redundancy patterns, we propose a simple zero-shot pruning method as a case study. Experiments on fine-tuning GLUE tasks verify its effectiveness. The comprehensive analyses on attention redundancy make model understanding and zero-shot model pruning promising.

Publication Details

Paper ID:
21801
Year:
2021
Publication:
TIPSTER
Publication Type:
conf
DOI:
nan