Transformer visualization with BertViz
Jesse Vig’s article, A Multiscale Visualization of Attention in the Transformer Model, 2019, recognizes the effectiveness of transformer models. However, Jesse Vig explains that deciphering the attention mechanism is challenging. The paper describes the process of BertViz, a visualization tool.
BertViz can visualize attention head activity and interpret a transformer model’s behavior.
BertViz was first designed to visualize BERT and GPT-3 models. In this section, we will visualize the activity of a BERT model.
Let’s now install and run BertViz.
Running BertViz
It only takes five steps to visualize transformer attention heads and interact with them.
Open the BertViz.ipynb
notebook in the Chapter14
directory in the GitHub repository of this book.
The first step is to install BertViz
and the requirements.
Step 1: Installing BertViz and importing the modules
The notebook installs BertViz
, Hugging...