🚀 德语Bert情感分类模型
本模型用于对德语文本进行情感分类。为达到最佳效果,所有模型输入都需采用与训练时相同的预处理步骤。为简化模型使用,我们提供了一个 Python 包,它集成了预处理和推理所需的代码。
该模型采用了谷歌的Bert架构,并在183.4万个德语样本上进行了训练。训练数据包含来自不同领域的文本,如 Twitter、Facebook 以及电影、应用和酒店评论等。你可以在论文中找到有关数据集和训练过程的更多信息。
🚀 快速开始
📦 安装指南
要开始使用,可从 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 库来训练此模型,结果比论文中报告的略好。
属性 |
详情 |
模型类型 |
基于谷歌Bert架构的情感分类模型 |
训练数据 |
包含来自 Twitter、Facebook、电影、应用和酒店评论等不同领域的183.4万个德语样本 |
引用
若你有反馈或疑问,请通过邮件或 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}
}
📄 许可证
本项目采用 MIT 许可证。