Student or educator? Sign up with your school email and get 6 months of Pro free.
CoChat

The DOI matches its Crossref record; 22 of the 22 references it cites were found in a registry or an index.

A Multiscale Visualization of Attention in the Transformer Model

Open access
Vig, Jesse · 2019 · Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics: System Demonstrations

Abstract

The Transformer is a sequence model that forgoes traditional recurrent architectures in favor of a fully attention-based approach.Besides improving performance, an advantage of using attention is that it can also help to interpret a model by showing how the model assigns weight to different input elements.However, the multi-layer, multi-head attention mechanism in the Transformer model can be difficult to decipher.To make the model more accessible, we introduce an open-source tool that visualizes attention at multiple scales, each of which provides a unique perspective on the attention mechanism.We demonstrate the tool on BERT and OpenAI GPT-2 and present three example use cases: detecting model bias, locating relevant attention heads, and linking neurons to model behavior.

Overview

The claims and statistics of this paper haven’t been checked yet.

Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.

A few free checks a day · papers already verified open instantly · results are public

Integrity signals

Registry

Crossref · 10.18653/v1/p19-3007

Cites

22 of 22 references verified0 citation errors · 0 not checkable

Statistics

Figures

Figure 1 Attention-head view for GPT-2, for the input text The quick, brown fox jumps over the lazy . The left and center figures represent different layers / attention heads. The right figure depicts the same layer/head as the center figure, but with the token lazy selected.
Figure 1 Attention-head view for GPT-2, for the input text The quick, brown fox jumps over the lazy . The left and center figures represent different layers / attention heads. The right figure depicts the same layer/head as the center figure, but with the token lazy selected.CC-BY · From the PDF
Image 2
CC-BY · From the PDF
Image 3
CC-BY · From the PDF
Figure 2 Attention-head view for BERT, for inputs the cat sat on the mat (Sentence A) and the cat lay on the rug (Sentence B). The left and center figures represent different layers / attention heads. The right figure depicts the same layer/head as the center figure, but with Sentence A → Sentence B fi lter selected.
Figure 2 Attention-head view for BERT, for inputs the cat sat on the mat (Sentence A) and the cat lay on the rug (Sentence B). The left and center figures represent different layers / attention heads. The right figure depicts the same layer/head as the center figure, but with Sentence A → Sentence B fi lter selected.CC-BY · From the PDF
Figure 3 Examples of attention heads in GPT-2 that capture specific lexical patterns: list items (left); verbs (center); and acronyms (right). Similar patterns were observed in these attention heads for other inputs. Attention directed toward first token is likely null attention (Vig and Belinkov, 2019).
Figure 3 Examples of attention heads in GPT-2 that capture specific lexical patterns: list items (left); verbs (center); and acronyms (right). Similar patterns were observed in these attention heads for other inputs. Attention directed toward first token is likely null attention (Vig and Belinkov, 2019).CC-BY · From the PDF
Figure 4 Attention pattern in GPT-2 related to coreference resolution suggests the model may encode gender bias.
Figure 4 Attention pattern in GPT-2 related to coreference resolution suggests the model may encode gender bias.CC-BY · From the PDF
Figure 5 Model view of BERT, for same inputs as in Figure 2. Excludes layers 4-11 and heads 6-11.
Figure 5 Model view of BERT, for same inputs as in Figure 2. Excludes layers 4-11 and heads 6-11.CC-BY · From the PDF
Figure 6 Neuron view of BERT for layer 0, head 0 (same one depicted in Figure 2, left). Positive and negative values are colored blue and orange, respectively, with color saturation based on magnitude of the value. As with the attention-head view, connecting lines are weighted based on attention between the words.
Figure 6 Neuron view of BERT for layer 0, head 0 (same one depicted in Figure 2, left). Positive and negative values are colored blue and orange, respectively, with color saturation based on magnitude of the value. As with the attention-head view, connecting lines are weighted based on attention between the words.CC-BY · From the PDF
Figure 7 Neuron view of GPT-2 for layer 1, head 10 (same one depicted in Figure 1, center) with last token selected. Blue arrows mark positions in the element-wise products where values decrease with increasing distance from the source token (becoming darker orange or lighter blue).
Figure 7 Neuron view of GPT-2 for layer 1, head 10 (same one depicted in Figure 1, center) with last token selected. Blue arrows mark positions in the element-wise products where values decrease with increasing distance from the source token (becoming darker orange or lighter blue).CC-BY · From the PDF

Verification

Claims the paper makes

The claims and statistics of this paper haven’t been checked yet.

Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.

A few free checks a day · papers already verified open instantly · results are public

Claims other papers make about this one

Each is checked against this paper’s own text: does it say what the citing paper says it does?

Self-check

Percentages, sums and reported differences re-computed from the paper’s own numbers.

The self-check needs the paper’s full text.

Citations

Cites

  • Attention Is All You Need

    Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., & Polosukhin, I. (2017) · arXiv · doi:10.48550/arxiv.1706.03762 · Cited by 120,404 · cited 2×

    “Jones (2017) designed a visualization tool specifically for multihead attention, which visualizes attention over multiple heads in a layer by superimposing their attention patterns (Vaswani et al., 2017, 2018).”
    Method
  • BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding

    Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2018) · arXiv · doi:10.48550/arxiv.1810.04805 · Cited by 73,173 · cited 1×

    “In 2018, the BERT (Bidirectional Encoder Representations from Transformers) language representation model achieved state-of-the-art performance across NLP tasks ranging from sentiment analysis to question answering (Devlin et al., 2018).”
    Background
  • BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding

    Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2019) · Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers) · doi:10.18653/v1/n19-1423 · Cited by 54,325 · cited 1×

    “In 2018, the BERT (Bidirectional Encoder Representations from Transformers) language representation model achieved state-of-the-art performance across NLP tasks ranging from sentiment analysis to question answering (Devlin et al., 2018).”
    Background
  • Neural Machine Translation by Jointly Learning to Align and Translate

    Bahdanau, D., Cho, K., & Bengio, Y. (2014) · arXiv · doi:10.48550/arxiv.1409.0473 · Cited by 16,213 · cited 3×

    “Various tools have been developed to visualize attention in NLP models, ranging from attention-matrix heatmaps (Bahdanau et al., 2015; Rush et al., 2015; Rocktäschel et al., 2016) to bipartite graph representations (Liu et al., 2018; Lee et al., 2017; Strobelt et al., 2018).”
    BackgroundMethod
  • Envisioning Information.

    Kemp, C. D., & Tufte, E. R. (1992) · Biometrics · doi:10.2307/2532323 · Cited by 2,713

  • A Neural Attention Model for Abstractive Sentence Summarization

    Rush, A. M., Chopra, S., & Weston, J. (2015) · Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing · doi:10.18653/v1/d15-1044 · Cited by 2,656 · cited 2×

    “Various tools have been developed to visualize attention in NLP models, ranging from attention-matrix heatmaps (Bahdanau et al., 2015; Rush et al., 2015; Rocktäschel et al., 2016) to bipartite graph representations (Liu et al., 2018; Lee et al., 2017; Strobelt et al., 2018).”
    Method
  • Attention is not Explanation

    Jain, S., & Wallace, B. (2019) · Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (NAACL-HLT) · doi:10.18653/v1/n19-1357 · Cited by 1,975 · cited 1×

    “, 2015; Belinkov and Glass, 2019), although its value in explaining individual predictions may be limited (Jain and Wallace, 2019).”
    Background
  • Analyzing Multi-Head Self-Attention: Specialized Heads Do the Heavy Lifting, the Rest Can Be Pruned

    Voita, E., Talbot, D., Moiseev, F., Sennrich, R., & Titov, I. (2019) · Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics · doi:10.18653/v1/p19-1580 · Cited by 1,146 · cited 2×

    “Recent work shows that attention in the Transformer correlates with syntactic constructs such as dependency relations and part-of-speech tags (Raganato and Tiedemann, 2018; Voita et al., 2019; Vig and Belinkov, 2019).”
    Background
  • Gender bias in coreference resolution: Evaluation and debiasing methods

    Zhao, J., Wang, T., Yatskar, M., Ordonez, V., & Chang, K.-W. (2018) · Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers) · doi:10.18653/v1/n18-2003 · Cited by 684 · cited 1×

    “This suggests that the model’s coreference mechanism may encode gender bias (Zhao et al., 2018; Lu et al., 2018).”
    Background
  • Tensor2Tensor for Neural Machine TranslationPreprint

    Vaswani, A., Samy Bengio, A., Brevdo, E., Chollet, F., Gomez, A. N., Gouws, S., Jones, L., Kaiser, Ł., Kalchbrenner, N., Parmar, N., et al. (2018) · arXiv (Cornell University) · doi:10.48550/arxiv.1803.07416 · Cited by 597 · cited 1×

    “Jones (2017) designed a visualization tool specifically for multi-head attention, which visualizes attention over multiple heads in a layer by superimposing their attention patterns (Vaswani et al., 2017, 2018).”

Show all 17 references

Research works printed but not linked: 1

  1. [18]18. Jesse Vig. 2019. BertViz: A tool for visualizing multi- head self-attention in the BERT model. In ICLR Workshop: Debugging Machine Learning Models.

Cited by

See all 792

Metadata

Authors
Vig, J.
Affiliations
Palo Alto Research Center (US)
Corresponding author
Vig, Jesse
Venue
Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics: System Demonstrations
Published
2019
Pages
37-42
OpenAlex
W2949202705
Cited by
600
References
17
Citations by year
2026: 46 · 2025: 87 · 2024: 79 · 2023: 112 · 2022: 84 · 2021: 112 · 2020: 71 · 2019: 9
FWCI
26.40
Type
conference paper
Language
en
Open access
Licence
cc-by
Locations
  • Annual Meeting of the Association for Computational Linguistics: System Demonstrations (ACL Demo) (publishedVersion, cc-by)
  • arXiv (Cornell University) (submittedVersion)
  • arXiv (Cornell University)
Topics
  • Physical Sciences › Computer Science › Artificial Intelligence › Explainable Artificial Intelligence (XAI)
  • Physical Sciences › Computer Science › Artificial Intelligence › Topic Modeling
  • Physical Sciences › Computer Science › Computer Graphics and Computer-Aided Design › Data Visualization and Analytics
Keywords
attention visualization, transformer models, multi-scale visualization, interpretability, multi-head attention, BERT, GPT-2, attention heads, open-source visualization tool

About these checks

Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.

Statistics and arithmetic are recomputed, not judged.

Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.

What counts as a claim ›How we measure confidence ›How we check this ›

Are you an author, or do you see a problem with this page? Request a review

How to cite

Cite CoChat for the checks on this page, and the paper for its own findings.

This page
CoChat. (2026). Citation check: A Multiscale Visualization of Attention in the Transformer Model. https://app.cochat.ai/papers/10.18653/v1/p19-3007
The paper
Vig, J. (2019). A Multiscale Visualization of Attention in the Transformer Model. Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics: System Demonstrations. https://doi.org/10.18653/v1/p19-3007

Data sources

Bibliographic data: Semantic Scholar, OpenAlex, Crossref.

Contains information from the Semantic Scholar Academic Graph Datasets, made available under the ODC Attribution License (ODC-BY 1.0).

Semantic Scholar’s data is described in: Kinney, R., et al. (2023). The Semantic Scholar Open Data Platform. arXiv:2301.10140.