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 prediction label type for span classifier #3432

Merged
merged 4 commits into from
Jul 8, 2024

Conversation

helpmefindaname
Copy link
Member

No description provided.

@helpmefindaname helpmefindaname force-pushed the span_classifier_ner_type branch from 0408e72 to c817b63 Compare June 14, 2024 12:25
@helpmefindaname helpmefindaname marked this pull request as ready for review June 14, 2024 13:11
@helpmefindaname helpmefindaname force-pushed the span_classifier_ner_type branch from c817b63 to 2bab651 Compare June 14, 2024 13:11
@helpmefindaname helpmefindaname force-pushed the span_classifier_ner_type branch from 2bab651 to 90480b2 Compare June 28, 2024 14:04
Copy link
Collaborator

@alanakbik alanakbik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently does not work. To reproduce:

from flair.data import Sentence
from flair.models import MultitaskModel

# For comparison: This works since the label type is "ner" for both models in the multitask model
classifier: MultitaskModel = MultitaskModel.load("zelda")

sentence = Sentence("Kirk and Spock met on the Enterprise")

classifier.predict(sentence)

print(sentence)

# Giving them sensible label names, now made possible with this PR
classifier.tasks["Task_1"]._label_type = "nel"
classifier.tasks["Task_1"]._span_label_type = "ner"

# However, this no longer makes predictions
sentence = Sentence("Kirk and Spock met on the Enterprise")

classifier.predict(sentence)

print(sentence)

The problem lies in the _filter_data_point method of the DefaultClassifier.

@alanakbik
Copy link
Collaborator

@helpmefindaname I've pushed a small fix for the issue. I'll approve now, but can you double beck before you merge?

@helpmefindaname helpmefindaname force-pushed the span_classifier_ner_type branch from c4833f4 to 1447745 Compare July 5, 2024 16:57
@helpmefindaname
Copy link
Member Author

@alanakbik good catch, I did a small change so we allow both, setting the span_label_type immediately (but training on label_type if available) and having it set later instead.

@alanakbik alanakbik merged commit c6a2643 into master Jul 8, 2024
1 check passed
@alanakbik alanakbik deleted the span_classifier_ner_type branch July 8, 2024 19:49
@alanakbik
Copy link
Collaborator

Thanks @helpmefindaname!

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 this pull request may close these issues.

2 participants