Skip to content
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

Add Primary Attribution support for BERT classification #64

Open
jalammar opened this issue Jan 17, 2022 · 4 comments
Open

Add Primary Attribution support for BERT classification #64

jalammar opened this issue Jan 17, 2022 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@jalammar
Copy link
Owner

Primary attribution are currently supported for causal (GPT) models and enc-dec (T5/T0) models. It would be great to add support for MLM models. A good first implementation would target either BERT or RoBERTa. My sense is that Sequence Classification takes precedent, then token classification.

BertForSequenceClassification
RobertaForSequenceClassification

Captum's Interpreting BERT Models guide is a good place to look.

As far as how to fit it into Ecco, these are initial ideas:

  • We'll need a way to indicate the classification head in init.py. Likely a new head config parameter .
  • We may have to add a 'predict()' or classify() method to lm.py. ("predict" to match the familiar sklearn api, "classify" to be more specific as generation is also prediction)
@jalammar jalammar added the help wanted Extra attention is needed label Jan 17, 2022
@guustfranssensEY
Copy link

Hey Jay,

Do I understand correctly that it is currently not possible to use Ecco for custom trained Bert models?

Or is it through the use of a custom model config or by passing it as a Pytorch model?
If so, is there more documentation on this besides the following

@jalammar
Copy link
Owner Author

It's possible to use custom bert models for neuron activation capture/factorization and CCA. But not yet for Primary Attribution.

@guustfranssensEY
Copy link

guustfranssensEY commented Jan 19, 2022

Good to hear that it is possible!
To your knowledge, is there example code that showcases how to get insights with Ecco from a custom Bert model trained from the AutoModelForSequenceClassification class?

I assume I will need to use the LM class instead of the from_pretrained()

@JoaoLages
Copy link
Contributor

It would be easy to implement this for MLMs as it requires a single forward step for classification. We would just need a new visualization from the JS side :)
Just wanted to point out that this package is already covering a lot of what you intend. Maybe it would be healthy to have a chat with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants