返回模型
说明文档
基于 Bert 的德语文本情感分类
该模型用于德语文本的情感分类。为了获得最佳效果,所有模型输入需要使用与训练时相同的预处理流程进行预处理。为了简化模型的使用,我们提供了一个 Python 包,将预处理和推理所需的代码捆绑在一起。
该模型使用了 Google 的 Bert 架构,并在 183.4 万个德语样本上进行了训练。训练数据包含来自不同领域的文本,如 Twitter、Facebook 以及电影、应用和酒店评论。 您可以在论文中找到有关数据集和训练过程的更多信息。
使用 Python 包
首先从 pypi 安装该包:
pip install germansentiment
from germansentiment import SentimentModel
model = SentimentModel()
texts = [
"Mit keinem guten Ergebniss","Das ist gar nicht mal so gut",
"Total awesome!","nicht so schlecht wie erwartet",
"Der Test verlief positiv.","Sie fährt ein grünes Auto."]
result = model.predict_sentiment(texts)
print(result)
上述代码将输出以下列表:
["negative","negative","positive","positive","neutral", "neutral"]
输出类别概率
from germansentiment import SentimentModel
model = SentimentModel()
classes, probabilities = model.predict_sentiment(["das ist super"], output_probabilities = True)
print(classes, probabilities)
['positive'] [[['positive', 0.9761366844177246], ['negative', 0.023540444672107697], ['neutral', 0.00032294404809363186]]]
模型和数据
如果您对训练该模型所使用的代码和数据感兴趣,请查看此仓库以及我们的论文。下面是该模型在不同数据集上取得的 F1 分数表。由于我们使用更新版本的 transformer 库训练了该模型,结果比论文中报告的略好。
| 数据集 | F1 分数 |
|---|---|
| holidaycheck | 0.9568 |
| scare | 0.9418 |
| filmstarts | 0.9021 |
| germeval | 0.7536 |
| PotTS | 0.6780 |
| emotions | 0.9649 |
| sb10k | 0.7376 |
| Leipzig Wikipedia Corpus 2016 | 0.9967 |
| 全部 | 0.9639 |
引用
如需反馈和问题,请通过邮件或 Twitter @oliverguhr联系我。如果您觉得有用,请引用我们:
@InProceedings{guhr-EtAl:2020:LREC,
author = {Guhr, Oliver and Schumann, Anne-Kathrin and Bahrmann, Frank and Böhme, Hans Joachim},
title = {Training a Broad-Coverage German Sentiment Classification Model for Dialog Systems},
booktitle = {Proceedings of The 12th Language Resources and Evaluation Conference},
month = {May},
year = {2020},
address = {Marseille, France},
publisher = {European Language Resources Association},
pages = {1620--1625},
url = {https://www.aclweb.org/anthology/2020.lrec-1.202}
}
oliverguhr/german-sentiment-bert
作者 oliverguhr
text-classification
transformers
↓ 216.6K
♥ 66
创建时间: 2022-03-02 23:29:05+00:00
更新时间: 2025-03-03 16:52:02+00:00
在 Hugging Face 上查看文件 (14)
.gitattributes
README.md
config.json
eval_results_germansentiment.txt
flax_model.msgpack
model.safetensors
onnx/config.json
onnx/model.onnx
ONNX
pytorch_model.bin
special_tokens_map.json
tf_model.h5
tokenizer_config.json
training_args.bin
vocab.txt