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

[Question]: Adjusting threshold for NER models #3340

Closed
lunik1 opened this issue Oct 16, 2023 · 2 comments
Closed

[Question]: Adjusting threshold for NER models #3340

lunik1 opened this issue Oct 16, 2023 · 2 comments
Labels
question Further information is requested

Comments

@lunik1
Copy link

lunik1 commented Oct 16, 2023

Question

Is is possible to adjust the threshold for the built in NER models? This was asked previously at #2865, but went unanswered.

@lunik1 lunik1 added the question Further information is requested label Oct 16, 2023
@helpmefindaname
Copy link
Collaborator

Hi @lunik1
There is no threshold implemented for ner, as the decoding is a bit more complex, so your question can be split into two parts:

  • Can I allow NER-Predictions with even lower confidence?
    • No you cannot, as Viterbi is just searching for the most likely sequence. If the tagging of the entity doesn't apear to be most likely, there is no easy way to recreate it.
  • Can I restrict NER-Predictions to require a certain confidence?
    • Yes, simply replace the for span in sentence.get_labels("ner") call with [span for span in sentence.get_labels("ner") if span.confidence > threshold] so you only operate on the spans with high enough confidence.

@lunik1
Copy link
Author

lunik1 commented Oct 17, 2023

Thank you for the quick response. Unfortunately I was trying to do the former.

@lunik1 lunik1 closed this as completed Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants