bertviz
Route BertViz Transformer attention visualization, neuron-view, notebook, and HTML export workflows.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- bertviz
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Route BertViz Transformer attention visualization, neuron-view, notebook, and HTML export workflows.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/environment-and-install.md2.6 KB
- 参考文档references/repo-provenance.md2.1 KB
- 参考文档references/repo-routing-metadata.json312 B
- 参考文档references/troubleshooting.md2.6 KB
- 脚本scripts/check_bertviz_environment.py4.2 KB
03 SKILL.md 正文
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
| User need | Read next |
|---|---|
| Visualize standard self-attention tensors from Hugging Face or another Transformer model. | sub-skills/attention-views/SKILL.md |
Render sentence-pair head/model views with sentence_b_start. |
sub-skills/attention-views/SKILL.md |
| Render encoder, decoder, or cross-attention for sequence-to-sequence models. | sub-skills/attention-views/SKILL.md |
| Save BertViz output as standalone HTML or use it outside a notebook display call. | sub-skills/attention-views/SKILL.md, or sub-skills/neuron-view/SKILL.md for neuron view |
| Inspect query/key neuron contributions using BertViz's modified model classes. | sub-skills/neuron-view/SKILL.md |
| Diagnose package installation, notebook display, PyTorch/IPython dependency, or JS asset issues. | references/troubleshooting.md |
| Check whether this skill matches the current BertViz checkout/version. | references/repo-provenance.md |
Core distinctions
head_viewandmodel_viewconsume attention tensors. They are the right choice when the model can return Hugging Face-style attention weights withoutput_attentions=True.neuron_view.showcomputes 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
references/environment-and-install.mdexplains dependencies, notebook frontend expectations, backend assumptions, and offline validation strategy.references/troubleshooting.mdcovers cross-cutting install/import/display/runtime symptoms.references/repo-provenance.mdrecords the source snapshot and evidence paths used to build this skill.scripts/check_bertviz_environment.pychecks imports, function signatures, packaged JavaScript assets, and optional neuron-view imports without downloading models.
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, andneuron-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.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).