Alignment Attention by Matching Key and Query Distributions

Shujian Zhang, Xinjie Fan, Huangjie Zheng, Korawat Tanwisuth, Mingyuan Zhou
10/25/2021
cs.LGcs.CLstat.ML
transformer-attention

Official code: szhang42/alignment_attention (7 stars, Python, Apache-2.0, last commit 2022-07-29).

Abstract

The neural attention mechanism has been incorporated into deep neural networks to achieve state-of-the-art performance in various domains. Most such models use multi-head self-attention which is appealing for the ability to attend to information from different perspectives.

Show full abstract

This paper introduces alignment attention that explicitly encourages self-attention to match the distributions of the key and query within each head. The resulting alignment attention networks can be optimized as an unsupervised regularization in the existing attention framework. It is simple to convert any models with self-attention, including pre-trained ones, to the proposed alignment attention. On a variety of language understanding tasks, we show the effectiveness of our method in accuracy, uncertainty estimation, generalization across domains, and robustness to adversarial attacks. We further demonstrate the general applicability of our approach on graph attention and visual question answering, showing the great potential of incorporating our alignment method into various attention-related tasks.

View on arXivView PDF

Code Implementations(1)

Apache-2.0
72Python, Jupyter NotebookOct 19, 20214 years agoApache-2.0

Similar Papers

Cite this paper

@article{zhang2021alignment,
  title  = {Alignment Attention by Matching Key and Query Distributions},
  author = {Shujian Zhang and Xinjie Fan and Huangjie Zheng and Korawat Tanwisuth and Mingyuan Zhou},
  year   = {2021},
  eprint = {2110.12567},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2110.12567}
}

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

Discussion