Giter Site home page Giter Site logo

frankaging / bert-lrp Goto Github PK

View Code? Open in Web Editor NEW
30.0 3.0 9.0 5.03 MB

On Explaining Your Explanations of BERT: An Empirical Study with Sequence Classification

Home Page: https://arxiv.org/abs/2101.00196

License: MIT License

Python 1.97% Shell 0.01% Jupyter Notebook 98.02%
bert mutli-gpu attribution-extraction ready-to-use sensitivity-analysis sentiment-analysis relevance-scores decision gradient-hooks attribution-methods

bert-lrp's People

Contributors

frankaging avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bert-lrp's Issues

Bug report

In train_helper.py line 612, I think the "train_features" should be "test_features" to load the segment_ids.

word-deletion-correct.tsv

Hi!
Thanks for sharing this amazing work!
A question : how do you calculate the dataframe in word-deletion-correct.tsv file you use in order to plot figure 1 in the paper?
Thanks!

Question about the implemented LRP rules

Thank you for this great work.
Maybe you didn't realize it, Your implemented LRP rules are actually quite different than that has been proposed in this area.... based on my test, your implementation actually beat XAI SOTA algorithm published recently on some datasets...

That's said... while they work... I don't understand the intuition .... I would appreciate it if you can share some of insights.

First, The Linear alpha-beta rule: It looks like you implemented a modified version of alpha-beta rule
https://github.com/frankaging/BERT_LRP/blob/57f44c1bd7c1e3886110402652690b75e4ac0f67/code/util/lrp.py#L24-L44

The original alpha beta rule is in the following form:
$$R_j = \sum_{k} \alpha \frac{(a_j w_{jk})^+ }{\sum (a_j w_{jk})^+ } + \beta \frac{(a_j w_{jk})^- }{\sum (a_j w_{jk})^- } $$.

And what you implemented is in the following form:
$$R_j = \sum_{k} \alpha \frac{a_j w_{jk}^+ }{\sum a_j w_{jk}^+ } + \beta \frac{a_j w_{jk}^- }{\sum a_j w_{jk}^- } $$.

So the original rule preallocate alpha and beta portion of relevance towards positive and negative of (weight* input), while you allocate alpha and beta portion towards (pos_weight * input) and (neg_weight * input).

I don't understand the intuition behind this rule, because the input of linear layer in bert may not be strictly positive... so I don't understand why do we purely allocate a fixed portion of relevance to inputs based on the sign of associated weights.

Also, looking at how you are dealing with other layers, it seems you are directly using relevance multiplying the gradient of the layer's output to the input, for example, you did the skip connection as following:
https://github.com/frankaging/BERT_LRP/blob/57f44c1bd7c1e3886110402652690b75e4ac0f67/code/model/BERT.py#L647-L650

Can you share some insights what does this represent? I haven't seen anything like this before.....

It seems to me that you have done a lot of different tricks (these two above, the way you normalize the relevance after linear layer and how you force to take absolute value of relevance at the end despite the relevance are signed) that are quite different than what has been published in this area. To be honest, some of them don't make too much sense... but since they performs well on NLP tasks I've been testing... there must be things I don't understand/worth exploring

Have you tried these rules on other types of transformer (like VIT)? I adapted these rules on VIT...the result is not as good.. but maybe I made some mistakes in the code.. not sure.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.