-
Notifications
You must be signed in to change notification settings - Fork 32
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
Proper way of handling classifier heads in Transformers #192
Comments
Hey Krzysztof, thanks a lot for working on this, I am really excited to see this working in Zennit at some point. From your minimal example, I cannot see an immediate problem (this indeed runs However, looking at the Huggingface transformer implementation, I heavily Although, back in the day, I drafted #168 to implement multiple inputs (but not outputs), I did I decided to postpone the param relevances, which are somewhat less important, Unfortunately, we will probably not be able to get the Transformers working |
Hi Christopher, Sorry for the late response and thank you for pointing out the single-input/single-output limitations. Indeed, this seems like the issue here. I'm in no massive rush, since we have also had some success with applying Shapley Value explanations to the language models we're using for our project but I'd still be willing to devote some time to getting CLRP working in the scope of Zennit. I think Zennit is the most mature and the most well-thought-out XAI framework for PyTorch created to date, so it makes sense to pool all the efforts into Zennit instead of creating custom, less portable implementations of the idea elsewhere. I will hang around and watch #196 and once it's done I will try my hand at implementing CLRP Rules. Thank you so so much for creating and maintaining this project! It is a massive help to the XAI community. |
Hi,
I am attempting to implement Conservative LRP rules as part of #184 since I need it for a university project. I am running into certain issues with the classifier heads and was hoping you could point out what I'm potentially doing wrong.
I have so far implemented a composite in the following manner:
Where
AHConservative
andLNConservative
are Rules described in the CLRP Paper.I have also implemented a custom attributor which calculates relevance scores with respect to the embeddings (since integer inputs are not differentiable). However the problem I am facing seems to appear also with a basic
Gradient
attributor. Here is a minimal example:Working with
BertForSequenceClassification
from the Huggingfacetransformers
library the classifier head is annn.Linear
module with the size(768, 2)
. I am however getting an error from theEpsilon
rule, specifically from thegradient_mapper
:I do understand that the tensor sizes must agree for division in the
gradient_mapper
. I am therefore suspecting I'm mishandling the classifier head but I am not sure how to proceed. Should I upsample the output to the size of input and just useEpsilon
? Should I implement a custom rule? Any help would be largely appreciated! I'd love to get a rough implementation of the changes suggested in #184 working so we could push the needle on XAI for Transformers a bit.The text was updated successfully, but these errors were encountered: