Transformer Dissection: A Unified Understanding of Transformer's Attention via the Lens of Kernel

Yao-Hung Hubert Tsai, Shaojie Bai, Makoto Yamada, Louis-Philippe Morency, Ruslan Salakhutdinov
8/30/2019
cs.LGstat.ML
transformer-attention

Official code: yaohungt/TransformerDissection (53 stars, last commit 2019-11-26).

Abstract

Transformer is a powerful architecture that achieves superior performance on various sequence learning tasks, including neural machine translation, language understanding, and sequence prediction. At the core of the Transformer is the attention mechanism, which concurrently processes all inputs in the streams.

Show full abstract

In this paper, we present a new formulation of attention via the lens of the kernel. To be more precise, we realize that the attention can be seen as applying kernel smoother over the inputs with the kernel scores being the similarities between inputs. This new formulation gives us a better way to understand individual components of the Transformer's attention, such as the better way to integrate the positional embedding. Another important advantage of our kernel-based formulation is that it paves the way to a larger space of composing Transformer's attention. As an example, we propose a new variant of Transformer's attention which models the input as a product of symmetric kernels. This approach achieves competitive performance to the current state of the art model with less computation. In our experiments, we empirically study different kernel construction strategies on two widely used tasks: neural machine translation and sequence prediction.

View on arXivView PDF

Code Implementations(1)

[EMNLP'19] Summary for Transformer Understanding

536Oct 9, 20197 years ago

Similar Papers

Cite this paper

@article{tsai2019transformer,
  title  = {Transformer Dissection: A Unified Understanding of Transformer's Attention via the Lens of Kernel},
  author = {Yao-Hung Hubert Tsai and Shaojie Bai and Makoto Yamada and Louis-Philippe Morency and Ruslan Salakhutdinov},
  year   = {2019},
  eprint = {1908.11775},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1908.11775}
}

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

Discussion