Comments (1)
Hi @rpryzant,
Thank you very much for the suggestions and input, this package is super nascent at the moment and there are a lot of things I would like to change going forward with it many of which you have mentioned here. I'm going to address each of your comments point by point as I think that's easiest:
- Totally in agreement on this, it's my biggest issue with the package at the moment aswell especially since I've been working on a question answering explainer and the design of the constructor has kind of started to fall apart. I'm going to separate the constructor from the instantiated object. At the time I guess I really liked the idea of a one liner but it doesn't really work well and the two behaviors are confusing.
The only change I would make to the example you provided is that I would try and keep the instance of the explainer as a callable rather than invoking a explain
method, I would be interested though in why you would do it this way. Also when you refer to the products of the inference and attribution living in the same versus different object I couldn't see a significant difference between your first and last example other than text being a required argument to the explain method.
This is how I would go about structuring the interface:
explainer = SequenceClassificationExplainer(model, tokenizer)
for text, label in zip(texts, labels):
attributions = explainer(text= text, index=1)
print(attributions.word_attributions)
print(attributions.predicted_class_index)
-
You're right I think this is a layover of an old bug I was having with the visualizer where I was casting everything to string for safety. I'm doing two different behaviors here for models of different types i.e. models that have a single node output are having the class cast to a int (either 0 or 1) whereas models that have multi-node ouputs have the true class cast to a string. I'll definitely fix this although I don't think it should be causing any major issues as the type casting here is purely cosmetic.
-
I think you be incorrect here, from what I can see I am using
ref_input_ids
which is special tokens plus pads for attributions, when token type ids and position ids are available I also use their reference type ids as well. The team at Captum were very helpful recently in helping me figure out how to pass reference ids for token type and position ids you can check that out here pytorch/captum#624 -
Yep it does, that's probably going to go in the next update.
-
The latest version should be returning the iPython HTML object in
visualize
, writing to a file has been optional from the start I believe.
Thank you again for this input, I really appreciate it especially at this stage of the project, I think it has a lot of room to grow but I need to figure out interface issues like those you have highlighted first. Would love to hear any other suggestions you might have in the future.
from transformers-interpret.
Related Issues (20)
- What algorithm is used to visualize text in SequenceClassificationExplainer
- How to use transformers-interpret for sequencelabelling, for example layoutlmv3 or v3 HOT 1
- MultiLabelSequenceClassificationExplainer potentially bugged. HOT 14
- ImportError: cannot import name 'PairwiseSequenceClassificationExplainer' HOT 1
- How to interpret the model fine tuning on the pre-trained ViT model using the imagery with larger resolution (500 * 500) than the pre-trained dataset (224 * 224)
- Token Classification Memory Issue
- Issue using BertTokenizer (AttributeError) HOT 2
- 'Bert' object has no attribute 'config'
- Text attribution fails for XLM-Roberta models HOT 4
- Is it normal that attribution takes multiple seconds per text, even on a GPU? HOT 1
- ZeroShotClassificationExplainer appears to be broken
- Prediction differs from non-explainable evaluation HOT 1
- Output probability - SequenceClassificationExplainer
- Support for Summarization models HOT 3
- Support for Longformer
- ImageClassificationExplainer: AttributeError: ndim when trying to visualize. HOT 3
- Issue with Zero Shot Classifier
- How to use other types of transformers models? HOT 1
- Support for Reformer
- Broken link for Captum Algorithm Overview in the README
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transformers-interpret.