荷兰情绪分析 RobBERT

发布于 2025-01-16 05:16:45 字数 742 浏览 4 评论 0原文

我有一个关于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

番薯 2025-01-23 05:16:45

当我使用“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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文