Attention Flows: Analyzing and Comparing Attention Mechanisms in Language Models

Joseph DeRose, Jiayao Wang, Matthew Berger

View presentation:2020-10-28T15:15:00ZGMT-0600Change your timezone on the schedule page
2020-10-28T15:15:00Z
Exemplar figure
We present Attention Flows, a visual tool for analyzing and comparing attention mechanisms in language models. Our approach supports the comparison of attention mechanisms in language models. We compare the BERT model (turquoise) and its fine-tuned counterpart (purple) tasked with determining question-answer pair validity (a). By selecting the word “what”, in contrast to BERT, the fine-tuned model attends to the answer “jacksonvillians or jaxons” (c), with full sentence context shown in (b).
Fast forward

Direct link to video on YouTube: https://youtu.be/rz3BpEVpS7E

Keywords

NLP, Transformer, Visual Analytics

Abstract

Advances in language modeling have led to the development of deep attention-based models that are performant across a wide variety of natural language processing (NLP) problems. These language models are typified by a pre-training process on large unlabeled text corpora and subsequently fine-tuned for specific tasks. Although considerable work has been devoted to understanding the attention mechanisms of pre-trained models, it is less understood how a model's attention mechanisms change when trained for a target NLP task. In this paper, we propose a visual analytics approach to understanding fine-tuning in attention-based language models. Our visualization, Attention Flows, is designed to support users in querying, tracing, and comparing attention within layers, across layers, and amongst attention heads in Transformer-based language models. To help users gain insight on how a classification decision is made, our design is centered on depicting classification-based attention at the deepest layer and how attention from prior layers flows throughout words in the input. Attention Flows helps users understand such attention propagation for a single model, as well as for multiple models, to visually compare similarities and differences between pre-trained and fine-tuned models. We use Attention Flows to study attention mechanisms in various sentence understanding tasks and highlight how attention evolves to address the nuances of solving these tasks.