Structured Self-Attention Weights Encode Semantics in Sentiment Analysis

Zhengxuan Wu, Thanh-Son Nguyen, Desmond C. Ong
10/10/2020
cs.CLcs.AI
transformer-attention

Official code: frankaging/LAT-for-Transformer (6 stars, Jupyter Notebook, last commit 2020-10-08).

Abstract

Neural attention, especially the self-attention made popular by the Transformer, has become the workhorse of state-of-the-art natural language processing (NLP) models. Very recent work suggests that the self-attention in the Transformer encodes syntactic information; Here, we show that self-attention scores encode semantics by considering sentiment analysis tasks.

Show full abstract

In contrast to gradient-based feature attribution methods, we propose a simple and effective Layer-wise Attention Tracing (LAT) method to analyze structured attention weights. We apply our method to Transformer models trained on two tasks that have surface dissimilarities, but share common semantics---sentiment analysis of movie reviews and time-series valence prediction in life story narratives. Across both tasks, words with high aggregated attention weights were rich in emotional semantics, as quantitatively validated by an emotion lexicon labeled by human annotators. Our results show that structured attention weights encode rich semantics in sentiment analysis, and match human interpretations of semantics.

View on arXivView PDF

Code Implementations(1)

Structured Self-Attention Weights Encode Semantics in Sentiment Analysis

62Jupyter Notebook, HTMLApr 24, 20206 years ago
attention-flowsattention-weightssemanticssentiment-analysis

Similar Papers

Cite this paper

@article{wu2020structured,
  title  = {Structured Self-Attention Weights Encode Semantics in Sentiment Analysis},
  author = {Zhengxuan Wu and Thanh-Son Nguyen and Desmond C. Ong},
  year   = {2020},
  eprint = {2010.04922},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2010.04922}
}

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

Discussion