name: bertviz
description: "Route BertViz Transformer attention visualization, neuron-view,
notebook, and HTML export workflows."
disable-model-invocation: true
metadata:
disco-role: operating
license: Apache 2.0
BertViz
Use this repo skill when a task involves BertViz, Transformer attention
visualization, head/model view rendering, neuron-level query/key inspection, or
saving BertViz notebook visualizations as HTML.
Install and quick check
For ordinary use:
pip install bertviz
For interactive notebooks also install and enable a notebook frontend such as
JupyterLab plus widgets:
pip install jupyterlab ipywidgets
Minimal package/API check:
python - <<'PY'
from bertviz import head_view, model_view
from bertviz.neuron_view import get_attention
print("bertviz import ok", head_view.__name__, model_view.__name__, get_attention.__name__)
PY
For a stronger no-network check, run scripts/check_bertviz_environment.py.
Route by task
Core distinctions
head_view and model_view consume attention tensors. They are the right
choice when the model can return Hugging Face-style attention weights with
output_attentions=True.
neuron_view.show computes a visualization payload from BertViz's modified
BERT/GPT-2/RoBERTa/XLNet classes because neuron view needs query and key
vectors, not only attention probabilities.
- BertViz is a visualization tool, not a model explanation guarantee. It helps
inspect attention patterns but should not be presented as proving causal
feature attribution.
Repo-level references and scripts
Safety defaults
- Do not run public notebooks or
from_pretrained(...) examples automatically
when network/model downloads are not explicitly allowed.
- Prefer bundled no-network helpers for validation: the root environment check,
attention-views/scripts/render_synthetic_attention.py, and
neuron-view/scripts/validate_toy_bert_attention.py.
- Keep generated outputs and saved HTML in user-chosen working directories;
BertViz does not require modifying its installed package files.