flair icon indicating copy to clipboard operation
flair copied to clipboard

bad result: "man was shot several times"= 99.6% POSITIVE sentiment

Open ldmtwo opened this issue 4 years ago • 2 comments

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}

ldmtwo avatar Feb 22 '22 01:02 ldmtwo

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.

HallerPatrick avatar Mar 19 '22 21:03 HallerPatrick

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.

stale[bot] avatar Jul 30 '22 19:07 stale[bot]