Interactive tool for visualizing attention in Transformer language models
Top 7.0% on sourcepulse
BertViz is an interactive visualization tool for understanding attention mechanisms in Transformer-based NLP models like BERT, GPT-2, and BART. It offers multiple views (Head, Model, Neuron) to analyze attention patterns, aiding researchers and practitioners in debugging and interpreting model behavior.
How It Works
BertViz leverages the Tensor2Tensor visualization tool, extending it with distinct views to dissect attention. The Head View displays attention for specific heads within a layer, the Model View provides a global overview across all layers and heads, and the Neuron View visualizes individual neuron contributions to attention computation. This multi-faceted approach offers a comprehensive understanding of how attention distributes information.
Quick Start & Requirements
pip install bertviz
pip install jupyterlab ipywidgets
output_attentions=True
when loading models.!pip install bertviz
.Highlighted Details
Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
The tool may perform slowly with very long inputs or large models; filtering layers is recommended. Some Colab visualizations may fail with long inputs due to runtime disconnections. The Neuron View is limited to specific custom BERT, GPT-2, and RoBERTa models included with the tool. Attention visualization does not directly equate to prediction explanation.
2 months ago
Inactive