hila-chefer / Transformer-MM-Explainability

[ICCV 2021- Oral] Official PyTorch implementation for Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers, a novel method to visualize any Transformer-based network. Including examples for DETR, VQA.
MIT License
801 stars 107 forks source link

Use non hacked models #29

Closed josh-freeman closed 1 year ago

josh-freeman commented 1 year ago

Is it possible to make it so that attn_probs and the other attrinbutes necessary for explainability are present on residual attention blocks of a model coming from here or here?

Cheerio

hila-chefer commented 1 year ago

Hi @josh-freeman, thanks for your interest!

Great question, sometimes you can use hooks and define those on the architecture without having to add code to save the attention maps and gradients, see this documentation this would require the architecture to have some layer that outputs the attention weights, which is not the case in all architectures.