Programming, Artificial Intelligence, Machine Learning, Data Science, Python.
outputs.attentions[-1][0, 0].detach().numpy() # Use the last layer's attention # Plotting sns.heatmap(attention, annot=True, fmt=".2f", xticklabels=tokenizer.tokenize("The quick brown fox jumps over the lazy dog"), yticklabels=tokenizer.tokenize("The quick brown fox jumps over the lazy dog"))