-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to interpret the visualization results? #15
Comments
TL;DR: This shows the relationship between input tokens Hi @mertyyanik! I can do my best here to explain what the visualization results mean. What I am plotting are all of the attention heads, for every head and every depth. To explain what an attention head is, let's look at
Basically, what I am plotting is Let's say that that you just wanted to encode the sentence "The dog ran.", that you wanted to pass through, for example, the Now, when it goes through the encoder, we get that this input vector of size (3, d_m) gets transformed into
Here, the word "The" routes 0.5 of its information through "The", and 0.5 of the information through "dog", "dog" routes all of its information through "dog", and "ran" routed all of its information through a mix of all 3. Finally, this is done for every head at every depth, and what one gets is a visualization of the internal representations. What exactly do these internal representations mean? Well, it depends on your task, but generally, it is how important the relationship is between two tokens. For some great articles and papers on how this stuff works, with more visualizations and better plots, I can link some other stuff here: https://towardsdatascience.com/deconstructing-bert-part-2-visualizing-the-inner-workings-of-attention-60a16d86b5c1 Now, what I described is how this works for standard attention. As for the Linformer attention... to be honest, it's hard to say. Recall that it is of the form
Where I can imagine when using the To give another small example for the convolutional method, imagine that you have 4 tokens, However, if one were to replace it with a linear layer or a fixed layer, I think that all interpretability goes through the drain, because the tokens can be totally dispersed throughout the whole head. However, this may actually be an open research question, and if you want to investigate further, feel free! I hope this answered your question! |
Thanks for the perfect explanation! |
Can you explain the visualization results? What is the meaning of each head plots?
The text was updated successfully, but these errors were encountered: