Tensorized Self-Attention: Efficiently Modeling Pairwise and Global Dependencies Together

Tao Shen, Tianyi Zhou, Guodong Long, Jing Jiang, Chengqi Zhang
5/2/2018
18 citations
cs.CLcs.AI
transformer-attention

Official code: taoshen58/DiSAN (312 stars, Python, Apache-2.0, last commit 2018-05-08). 1 more implementation below.

Abstract

Neural networks equipped with self-attention have parallelizable computation, light-weight structure, and the ability to capture both long-range and local dependencies. Further, their expressive power and performance can be boosted by using a vector to measure pairwise dependency, but this requires to expand the alignment matrix to a tensor, which results in memory and computation bottlenecks.

Show full abstract

In this paper, we propose a novel attention mechanism called "Multi-mask Tensorized Self-Attention" (MTSA), which is as fast and as memory-efficient as a CNN, but significantly outperforms previous CNN-/RNN-/attention-based models. MTSA 1) captures both pairwise (token2token) and global (source2token) dependencies by a novel compatibility function composed of dot-product and additive attentions, 2) uses a tensor to represent the feature-wise alignment scores for better expressive power but only requires parallelizable matrix multiplications, and 3) combines multi-head with multi-dimensional attentions, and applies a distinct positional mask to each head (subspace), so the memory and computation can be distributed to multiple heads, each with sequential information encoded independently. The experiments show that a CNN/RNN-free model based on MTSA achieves state-of-the-art or competitive performance on nine NLP benchmarks with compelling memory- and time-efficiency.

View on arXivView PDF

Code Implementations(2)

Code implementations of this paper
RepositoryTypeStarsLanguageLicenseLast commit
taoshen58/DiSANOfficial312PythonApache-2.02018-05-08
taoshen58/mtsaOfficial7Python–2019-06-02
taoshen58/DiSANOfficial100%
Apache-2.0

Code of Directional Self-Attention Network (DiSAN)

31267PythonNov 10, 20178 years agoApache-2.0
taoshen58/mtsaOfficial100%

Experimental Codes for Multi-mask Tensorized Self-Attention (MTSA)

71PythonApr 10, 20197 years ago
experimental

Similar Papers

Cite this paper

@article{shen2018tensorized,
  title  = {Tensorized Self-Attention: Efficiently Modeling Pairwise and Global Dependencies Together},
  author = {Tao Shen and Tianyi Zhou and Guodong Long and Jing Jiang and Chengqi Zhang},
  year   = {2018},
  eprint = {1805.00912},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1805.00912}
}

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

Discussion