[Paper Review] AttViz: Online exploration of self-attention for transparent neural language modeling
AttViz is an online, interactive toolkit for visualizing self-attention mechanisms in pre-trained language models, enabling researchers to explore attention weights across tokens and attention heads in real time. It provides intuitive visualizations of attention distributions and model output probabilities, offering insights into which tokens influence predictions—demonstrated on news classification tasks with BERT-based models.
Neural language models are becoming the prevailing methodology for the tasks of query answering, text classification, disambiguation, completion and translation. Commonly comprised of hundreds of millions of parameters, these neural network models offer state-of-the-art performance at the cost of interpretability; humans are no longer capable of tracing and understanding how decisions are being made. The attention mechanism, introduced initially for the task of translation, has been successfully adopted for other language-related tasks. We propose AttViz, an online toolkit for exploration of self-attention---real values associated with individual text tokens. We show how existing deep learning pipelines can produce outputs suitable for AttViz, offering novel visualizations of the attention heads and their aggregations with minimal effort, online. We show on examples of news segments how the proposed system can be used to inspect and potentially better understand what a model has learned (or emphasized).
Motivation & Objective
- To address the interpretability challenge in large neural language models, which are often treated as black boxes despite their high performance.
- To enable researchers and practitioners to inspect how attention mechanisms influence model predictions in real time.
- To provide an accessible, online interface for visualizing self-attention patterns across individual tokens and attention heads.
- To support transparent analysis of model decisions by linking attention distributions with output probability space.
- To facilitate the detection of salient tokens and potential biases in classification tasks such as hate speech or news topic classification.
Proposed method
- AttViz extracts attention weights from pre-trained transformer models (e.g., BERT) and maps them to a user-friendly, interactive web interface.
- It visualizes self-attention as heatmaps across input tokens, with color intensity indicating attention strength per head.
- The system enables dynamic aggregation of attention heads, allowing users to explore collective attention patterns.
- It synchronizes attention visualizations with model output probabilities, enabling side-by-side inspection of predictions and attention.
- The toolkit supports online exploration without requiring local computation or model fine-tuning.
- It leverages existing deep learning inference pipelines, requiring minimal integration effort to expose attention outputs for visualization.
Experimental results
Research questions
- RQ1How can self-attention patterns in transformer-based language models be effectively visualized for interpretability?
- RQ2Which tokens are most salient in influencing model predictions, and how do attention heads distribute this relevance?
- RQ3Can attention visualizations help identify spurious correlations or biases in model predictions?
- RQ4How do attention patterns differ across attention heads when classifying news segments?
- RQ5To what extent do first tokens in input sequences receive disproportionate attention, and why?
Key findings
- Tokens such as 'trillion', 'uk', and 'total' consistently received high self-attention values across multiple attention heads, indicating their relevance to the classification task.
- Only a subset of attention heads activated for individual tokens, suggesting that different heads focus on different aspects of the input, including potential relational patterns.
- The first token in input sequences was frequently emphasized, likely due to pre-training objectives that prioritize next-token prediction.
- The system successfully linked attention patterns with model output probabilities, revealing that the second-most likely class (e.g., politics) often aligns with semantic plausibility.
- AttViz enables real-time, interactive exploration of attention and prediction spaces, enhancing interpretability without requiring model retraining.
- The toolkit demonstrated utility in analyzing news text classification, particularly for detecting key terms and assessing model behavior in context.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.