荷兰情绪分析 RobBERT
我有一个关于 Python 中的荷兰语情感分析的问题。对于学校的一个项目,我想分析荷兰面试的情绪。我曾与维德合作过,但这在荷兰语中不起作用。于是我找到了RobBERT:一个基于荷兰语RoBERTa的语言模型。当我运行这段代码时,result1是一个肯定句,result2是一个否定句,肯定句有LABEL_0,得分为0.568,否定句也有LABEL_0,得分为0.533。这个输出是正确的还是我做错了什么,因为分数相差不大。提前致谢!
from transformers import RobertaTokenizer, RobertaForSequenceClassification
from transformers import pipeline
import torch
model_name = "pdelobelle/robbert-v2-dutch-base"
model = RobertaForSequenceClassification.from_pretrained(model_name)
tokenizer = RobertaTokenizer.from_pretrained(model_name)
classifier = pipeline('sentiment-analysis', model=model, tokenizer = tokenizer)
result1 = classifier('Ik vind het mooi')
result2 = classifier('Ik vind het lelijk')
print(result1)
print(result2)
I have a question about Dutch sentiment analysis in Python. For a project at school I want to analyse the sentiment of a Dutch interview. I have worked with Vader but that doesn't work in Dutch. So I found RobBERT: a Dutch RoBERTa-based language model. When I run this code, with result1 being a positive sentence and result2 a negative sentence, the positive sentence has LABEL_0 with a score of 0.568 and the negative sentence also LABEL_0 with a score of 0.533. Is this output right or am I doing something wrong because the scores do not differ much. Thanks in advance!
from transformers import RobertaTokenizer, RobertaForSequenceClassification
from transformers import pipeline
import torch
model_name = "pdelobelle/robbert-v2-dutch-base"
model = RobertaForSequenceClassification.from_pretrained(model_name)
tokenizer = RobertaTokenizer.from_pretrained(model_name)
classifier = pipeline('sentiment-analysis', model=model, tokenizer = tokenizer)
result1 = classifier('Ik vind het mooi')
result2 = classifier('Ik vind het lelijk')
print(result1)
print(result2)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我使用“DTAI-KULeuven/robbert-v2-dutch-sentiment”而不是“pdelobelle/robbert-v2-dutch-base”时,它按预期工作。
When I used 'DTAI-KULeuven/robbert-v2-dutch-sentiment' instead of 'pdelobelle/robbert-v2-dutch-base' it worked as expected.