BertViz is a visualization tool for understanding attention mechanisms in Transformer language models.
The tool addresses the challenge of interpreting how Transformer models allocate attention across input tokens by providing interactive visualizations that expose the internal workings of attention heads and layers. It works by hooking into Huggingface Transformer models and rendering attention weights through multiple complementary views: the head view shows attention patterns for specific heads within a layer, the model view provides an overview of attention across all layers and heads simultaneously, and the neuron view breaks down how individual neurons in query and key vectors contribute to computing attention scores.
Researchers and practitioners debugging Transformer behavior, understanding model predictions, or exploring how different architectures process language should consider this tool. It suits exploratory work in Jupyter notebooks and Colab environments where interactive visualization is valuable. The tool supports most Huggingface models, making it broadly applicable across BERT, GPT-2, RoBERTa, and other Transformer variants. The README does not name alternative visualization tools for comparison.
The project maintains active engagement with users through sample notebooks and an interactive Colab tutorial that allows experimentation without local setup. Development appears responsive to practical needs, as evidenced by support for multiple visualization perspectives and accommodation of different model architectures including encoder-decoder variants. The codebase includes documentation covering additional use cases beyond the basic examples.