Reinforced Self-Attention Network: a Hybrid of Hard and Soft Attention for Sequence Modeling

Tao Shen, Tianyi Zhou, Guodong Long, Jing Jiang, Sen Wang +1 more
1/31/2018
cs.CL
transformer-attention

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

Abstract

Many natural language processing tasks solely rely on sparse dependencies between a few tokens in a sentence. Soft attention mechanisms show promising performance in modeling local/global dependencies by soft probabilities between every two tokens, but they are not effective and efficient when applied to long sentences.

Show full abstract

By contrast, hard attention mechanisms directly select a subset of tokens but are difficult and inefficient to train due to their combinatorial nature. In this paper, we integrate both soft and hard attention into one context fusion model, "reinforced self-attention (ReSA)", for the mutual benefit of each other. In ReSA, a hard attention trims a sequence for a soft self-attention to process, while the soft attention feeds reward signals back to facilitate the training of the hard one. For this purpose, we develop a novel hard attention called "reinforced sequence sampling (RSS)", selecting tokens in parallel and trained via policy gradient. Using two RSS modules, ReSA efficiently extracts the sparse dependencies between each pair of selected tokens. We finally propose an RNN/CNN-free sentence-encoding model, "reinforced self-attention network (ReSAN)", solely based on ReSA. It achieves state-of-the-art performance on both Stanford Natural Language Inference (SNLI) and Sentences Involving Compositional Knowledge (SICK) datasets.

View on arXivView PDF

Code Implementations(1)

taoshen58/DiSANOfficial100%
Apache-2.0

Code of Directional Self-Attention Network (DiSAN)

31267PythonNov 10, 20178 years agoApache-2.0

Similar Papers

Cite this paper

@article{shen2018reinforced,
  title  = {Reinforced Self-Attention Network: a Hybrid of Hard and Soft Attention for Sequence Modeling},
  author = {Tao Shen and Tianyi Zhou and Guodong Long and Jing Jiang and Sen Wang and Chengqi Zhang},
  year   = {2018},
  eprint = {1801.10296},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1801.10296}
}

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

Discussion