模型:
oliverguhr/german-sentiment-bert
这个模型是用于德语文本情感分类的。为了取得最佳的结果,所有模型的输入都需要经过相同的预处理过程,这个预处理过程在训练过程中也被应用了。为了简化模型的使用,我们提供了一个Python包,其中包含了预处理和推断所需的代码。
该模型使用了Google的Bert架构,并且在183.4万个德语样本上进行了训练。训练数据包含了来自不同领域(如Twitter、Facebook以及电影、应用和酒店评论)的文本。您可以在 paper 中找到有关数据集和训练过程的更多信息。
要开始使用,请从 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]]]
如果您对用于训练此模型的代码和数据感兴趣,请参阅 this repository 和我们的 paper 。以下是该模型在不同数据集上达到的F1分数表。由于我们使用了transformer库的更新版本对该模型进行了训练,所以结果略好于论文中报告的结果。
| Dataset | F1 micro Score | 
|---|---|
| 12310321 | 0.9568 | 
| 12311321 | 0.9418 | 
| 12312321 | 0.9021 | 
| 12313321 | 0.7536 | 
| 12314321 | 0.6780 | 
| 12315321 | 0.9649 | 
| 12316321 | 0.7376 | 
| 12317321 | 0.9967 | 
| all | 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}
}