Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support for NER models#83

Answeredbycdpierse
pabvald asked this question inQ&A
Discussion options

Hi!

I have tried to generate explanations for NER models but I haven't found any description of how to implement this, so I have tried to extrapolate what is been already done for other tasks, such as multi-class classification.

I have followed the approach described in theCaptum tutorial to interpret BERT in which a custom forward function that allows to access a particular position of the prediction using theposition input argument is used and the attributions are computed with respect to theBertEmbeddings using thecaptum.attr.LayerIntegratedGradients class.

I have generated two types of visualizations:

  1. Attributions considering each token (position) and its corresponding predicted NER label: this allows to see how the rest of the sentence influenced each token to be classified into a particular NER class.
  2. Attributions considering a single token and all the possible NER classes: this allows to see how the rest of the sentence influenced a certain token to be classified into a class and not into any of the others.

A notebook with these two visualizations can be found inthis repo. I would like to know if my approach makes sense, or, if not, what I should do to correctly visualize explanations for NER models. Once I am sure my approach is right, I would like to contribute toTransformers Interpret implementing the support for NER models.

Thank you in advance for the help!

You must be logged in to vote

Hi@pabvald,

Thank you very much for putting the time into looking into this. I'd love to get the NER explainer finished to round out the capabilities of the text part of the package.

I think the approach you are taking for the first visualization is the right way to go. For most people my assumption is that they will want to just explore why a certain word was given a NER label, if there are requests for exploring all possible classes we could explore that at a later time, but the first use case seems like the most practical.

Your approach seems to be right from what I've looked at so far, would be delighted if you were up for contributing this feature, it'd be a major boost for the pack…

Replies: 1 comment 1 reply

Comment options

Hi@pabvald,

Thank you very much for putting the time into looking into this. I'd love to get the NER explainer finished to round out the capabilities of the text part of the package.

I think the approach you are taking for the first visualization is the right way to go. For most people my assumption is that they will want to just explore why a certain word was given a NER label, if there are requests for exploring all possible classes we could explore that at a later time, but the first use case seems like the most practical.

Your approach seems to be right from what I've looked at so far, would be delighted if you were up for contributing this feature, it'd be a major boost for the package. If you take a look at thisMulti-Label Explainer
it should give a good idea of how you can use the existing explainer class and utils to create a subclassed NER explainer. One custom feature I wanted to include for NER was the ability to pass the name or index of certain NER labels that are to be ignored by the explainer. This will make explanations for very long sentences much nicer to read.

If you need any help at all with this let me know.

Thanks again,
Charles

You must be logged in to vote
1 reply
@pabvald
Comment options

Hi@cdpierse,

great! I will work on it and include the feature you suggest.

Thank you for you answer,
Pablo

Answer selected bycdpierse
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@pabvald@cdpierse

[8]ページ先頭

©2009-2026 Movatter.jp