You*_*cef 2 python nlp sentiment-analysis huggingface-transformers
我正在使用 Hugging-face 管道进行情绪分析任务,它为我提供积极/消极情绪以及置信度得分。就我而言,我需要三个输出(正/中性/负)。问题是,即使是中性句子(例如:“他有她有”),拥抱脸也会给我很高的置信度分数?有什么建议么?
from transformers import pipeline
model = pipeline(task = 'sentiment-analysis')
sentence = 'some text to evaluate'
predicted = model(sentence)
print(predicted)
Run Code Online (Sandbox Code Playgroud)
以下是一些输出示例:
----------------------------------------------
sentence = 'I love you'
predicted = model(sentence)
predicted
[{'label': 'POSITIVE', 'score': 0.9998656511306763}]
----------------------------------------------
sentence = 'I hate you'
predicted = model(sentence)
predicted
[{'label': 'NEGATIVE', 'score': 0.9991129040718079}]
----------------------------------------------
sentence = 'I have she had'
predicted = model(sentence)
predicted
[{'label': 'POSITIVE', 'score': 0.9821817874908447}]
----------------------------------------------
sentence = 'I go to work'
predicted = model(sentence)
predicted
[{'label': 'POSITIVE', 'score': 0.9457777738571167}]
----------------------------------------------
sentence = 'This movie was actually neither that funny, nor super witty.'
predicted = model(sentence)
predicted
[{'label': 'NEGATIVE', 'score': 0.9997298121452332}]
Run Code Online (Sandbox Code Playgroud)
model = pipeline('sentiment-analysis', model="finiteautomata/bertweet-base-sentiment-analysis")`
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1555 次 |
| 最近记录: |