Closed entrity closed 1 year ago
Hi @entrity, Yes, it really applies the technique from the paper. As mentioned in the paper, we support all attention based architectures, including pure self attention (ViT or CLIP). For pure self attention models the co attention rules are not required, however this is not a simple visualization of the attention maps. We weight the attention by the gradients in order to average across the attention heads. You can also control the number of layers you wish to propagate back from.
overall- the answer is yes, this is the method from the paper, applied over a pure self attention model. We have similar experiments in the paper with ViT and a notebook for that as well.
The top of this repo's README links the article [ICCV 2021- Oral] PyTorch Implementation of Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers, but I'm looking at the
CLIP_explainability.ipynb
notebook, and it appears to me as if this does not demonstrate the technique introduced by the paper. Have I missed something? Or should this notebook be updated?Each of the examples in the notebook does no more than give heatmaps using the output of the helper function
interpret
, which makes use of simple self-attention, whereas the publication computed self-attention with effects from co-attention (cf. equation 11).Here's a relevant excerpt from
interpret
with comments to indicate correspondence between the python code and the publication. Equation 11 is absent.