flair
flair copied to clipboard
bad result: "man was shot several times"= 99.6% POSITIVE sentiment
I've been debugging bad output from the pretrained model. What corpus is this trained on? How to make it not overfit.
import flair
# !pip install GIT+https://github.com/flairNLP/flair.git
flair_sentiment = flair.models.TextClassifier.load('en-sentiment')
def sentiment(text):
s = flair.data.Sentence(text)
flair_sentiment.predict(s)
ret = {obj.value:obj.score for obj in s.labels}
return ret
# sentence = 'Texas good samaritan shot several times while saving woman from suspect'
# sentence = 'Art ran really well, but died.'
sentence = 'man was shot several times'
{'POSITIVE': 0.9961583018302917}
sentiment('I went to Palestine')
{'NEGATIVE': 0.9425508379936218}
sentiment('Black people in the South')
{'NEGATIVE': 0.8325328826904297}
Hey, I ran you code and getting a different result here:
man was shot several times
{'NEGATIVE': 0.9908545017242432}
I went to Palestine
{'NEGATIVE': 0.9425508379936218}
Black people in the South
{'NEGATIVE': 0.8325329422950745}
Looks like man was shot several times gives quite the opposite result to yours. In your example it is also not passed to the sentiment function.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.