Let’s go over the solution for each of the tasks from the challenge step by step.

Task 1 solution

First, let’s outline the steps needed to successfully visualize the attention heads of the provided sentences.

Import BertViz and Hugging Face modules

To start off, we will import BertViz and Hugging Face modules from which we can visualize the attention heads from a model view and an individual attention head view:

Get hands-on with 1200+ tech skills courses.