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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to enter custom id2label dicts in init #25

Closed
cdpierse opened this issue Mar 10, 2021 · 2 comments 路 Fixed by #41
Closed

add option to enter custom id2label dicts in init #25

cdpierse opened this issue Mar 10, 2021 · 2 comments 路 Fixed by #41
Assignees

Comments

@cdpierse
Copy link
Owner

No description provided.

@cdpierse cdpierse self-assigned this Mar 10, 2021
@lalitpagaria
Copy link
Contributor

I can contribute if you guide me.
As far as I understood explainer base class need to pass customer dict to PretrainedConfig during init.

@cdpierse
Copy link
Owner Author

@lalitpagaria that would be really helpful thanks. So because this only applies to sequence classification tasks I think the best place to implement this would be in the __init__ of the SequenceClassificationExplainer.

On the API level I see it looking something like

cls_explainer = SequenceClassificationExplainer(model, tokenizer, custom_id2label = {0: "my_label1", 1: "my_label2"})

Where custom_id2label is a optional parameter that can passed and will set the new values. I don't think you even need to overwrite id2label on the HF model's config itself because the classification explainer sets these as attributes itself so changing it for the explainer should do, I try as much as possible not to interfere with HF model itself.

Some other things that would be nice to do before actually setting the new values would be to check that the length of custom_id2label.keys() matches the existing length. In a case where a user accidentally sets too few or too many labels I would see it raising some sort of value error.

Another thing that this has got me thinking is that once the new id2label is set it would be to set label2id with the inverse values.

Thanks for volunteering to help on this, let me know if you need any further guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants