German Emotions
G
German Emotions
由 ChrisLalk 开发
基于XLM-RoBERTa的德语情绪分类模型,可识别28种情绪
下载量 299
发布时间 : 7/15/2024
模型简介
本模型是arpanghoshal/EmoRoBERTa的德语翻译版本,使用翻译后的go_emotions数据集对XLM-RoBERTa-base进行微调,专门用于德语文本的情绪分类任务。
模型特点
多情绪分类
能够识别德语文本中的28种不同情绪状态
跨语言迁移
基于多语言XLM-RoBERTa模型,通过翻译数据实现英语到德语的情绪分类能力迁移
医疗应用优化
特别关注医疗领域的情绪识别需求,模型在相关场景下表现良好
模型能力
德语文本情绪分类
多标签情绪识别
心理治疗文本分析
使用案例
心理健康
心理治疗会话分析
分析心理治疗过程中的患者情绪变化
可用于治疗进展监测和效果评估
情绪状态监测
长期跟踪患者的情绪波动模式
辅助诊断和个性化治疗计划制定
客户服务
客户反馈情绪分析
分析德语客户的反馈情绪
识别不满客户并优先处理
🚀 德语情感分类模型
这是一个用于德语情感分类的模型,它基于FacebookAI/xlm - roberta - base
模型,使用go_emotions
数据集的德语翻译版本进行微调。该模型能够对德语转录文本中的28种情感进行分类,为德语情感分析提供了有力支持。
🚀 快速开始
本模型可对德语转录文本中的28种情感进行分类。我们使用了go_emotions
数据集,将其翻译成德语,并对FacebookAI/xlm - roberta - base
模型进行了微调。该模型能够识别的28种情感包括:“钦佩”、“愉悦”、“愤怒”、“恼怒”、“认可”、“关心”、“困惑”、“好奇”、“渴望”、“失望”、“不认可”、“厌恶”、“尴尬”、“兴奋”、“恐惧”、“感激”、“悲痛”、“喜悦”、“爱”、“紧张”、“乐观”、“自豪”、“领悟”、“宽慰”、“懊悔”、“悲伤”、“惊讶”、“中立”。更多详细信息请参考文末发表的论文。
✨ 主要特性
- 语言支持:专注于德语情感分类,适用于德语转录文本。
- 情感种类丰富:能够识别28种不同的情感,满足多样化的情感分析需求。
- 模型基础:基于
FacebookAI/xlm - roberta - base
模型微调,具有较好的泛化能力。
📦 安装指南
在使用该模型前,你需要安装相关依赖库:
pip install transformers[torch]
pip install pandas, transformers, numpy, tqdm, openpyxl
💻 使用示例
基础用法
# pip install transformers[torch]
# pip install pandas, transformers, numpy, tqdm, openpyxl
import pandas as pd
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification, Trainer
import numpy as np
from tqdm import tqdm
import time
import os
from transformers import DataCollatorWithPadding
import json
# create base path and input and output path for the model folder and the file folder
base_path = "/share/users/staff/c/clalk/Emotionen"
model_path = os.path.join(base_path, 'Modell')
file_path = os.path.join(base_path, 'Datensatz')
MODEL = "ChrisLalk/German-Emotions"
tokenizer = AutoTokenizer.from_pretrained(MODEL, do_lower_case=False)
model = AutoModelForSequenceClassification.from_pretrained(
model_path,
from_tf=False,
from_flax=False,
trust_remote_code=False,
num_labels=28,
ignore_mismatched_sizes=True
)
data_collator = DataCollatorWithPadding(tokenizer=tokenizer)
# Path to the file
os.chdir(file_path)
df_full = pd.read_excel("speech_turns_pat.xlsx", index_col=None)
if 'Unnamed: 0' in df_full.columns:
df_full = df_full.drop(columns=['Unnamed: 0'])
df_full.reset_index(drop=True, inplace=True)
# Tokenization and inference function
def infer_texts(texts):
tokenized_texts = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)
class SimpleDataset:
def __init__(self, tokenized_texts):
self.tokenized_texts = tokenized_texts
def __len__(self):
return len(self.tokenized_texts["input_ids"])
def __getitem__(self, idx):
return {k: v[idx] for k, v in self.tokenized_texts.items()}
test_dataset = SimpleDataset(tokenized_texts)
trainer = Trainer(model=model, data_collator=data_collator)
predictions = trainer.predict(test_dataset)
sigmoid = torch.nn.Sigmoid()
probs = sigmoid(torch.Tensor(predictions.predictions))
return np.round(np.array(probs), 3).tolist()
start_time = time.time()
df = df_full
# Save results in a dict, here the df contains the additional variables File, Class, session, short_id, long_id, Prediction, hscl-11, and srs.
# However, only the "Sentence" column with the text is relevant for the pipeline.
results = []
for index, row in tqdm(df.iterrows(), total=df.shape[0]):
patient_texts = row['Patient']
prob_list = infer_texts(patient_texts)
results.append({
"File": row['Class']+"_"+row['session'],
"Class": row['Class'],
"session": row['session'],
"short_id": row["short_id"],
"long_id": row["long_id"],
"Sentence": patient_texts,
"Prediction": prob_list[0],
"hscl-11": row["Gesamtscore_hscl"],
"srs": row["srs_ges"],
})
# Convert results to df
df_results = pd.DataFrame(results)
df_results.to_json("emo_speech_turn_inference.json")
end_time = time.time()
elapsed_time = end_time - start_time
print(f"Elapsed time: {elapsed_time:.2f} seconds")
print(df_results)
emo_df = pd.DataFrame(df_results['Prediction'].tolist(), index=df_results["Class"].index)
col_names = ['admiration', 'amusement', 'anger', 'annoyance', 'approval', 'caring', 'confusion', 'curiosity', 'desire', 'disappointment', 'disapproval', 'disgust', 'embarrassment', 'excitement', 'fear', 'gratitude', 'grief', 'joy', 'love', 'nervousness', 'optimism', 'pride', 'realization', 'relief', 'remorse', 'sadness', 'surprise', 'neutral']
emo_df.columns = col_names
print(emo_df)
📚 详细文档
模型详情
属性 | 详情 |
---|---|
模型类型 | 文本分类 |
语言 (NLP) | 德语 |
许可证 | apache - 2.0 |
微调基础模型 | FacebookAI/xlm - roberta - base |
超参数 | 轮数:10;学习率:3e - 5;权重衰减:0.01 |
指标 | F1宏观:0.45;准确率:0.41;kappa值:0.42 |
分类指标
情感 | 情感倾向 | F1值 | Cohen’s Kappa值 |
---|---|---|---|
钦佩 | 积极 | 0.64 | 0.601 |
愉悦 | 积极 | 0.78 | 0.767 |
愤怒 | 消极 | 0.38 | 0.358 |
恼怒 | 消极 | 0.27 | 0.229 |
认可 | 积极 | 0.34 | 0.293 |
关心 | 积极 | 0.38 | 0.365 |
困惑 | 消极 | 0.40 | 0.378 |
好奇 | 积极 | 0.51 | 0.486 |
渴望 | 积极 | 0.39 | 0.387 |
失望 | 消极 | 0.19 | 0.170 |
不认可 | 消极 | 0.32 | 0.286 |
厌恶 | 消极 | 0.41 | 0.395 |
尴尬 | 消极 | 0.37 | 0.367 |
兴奋 | 积极 | 0.35 | 0.339 |
恐惧 | 消极 | 0.59 | 0.584 |
感激 | 积极 | 0.89 | 0.882 |
悲痛 | 消极 | 0.31 | 0.307 |
喜悦 | 积极 | 0.51 | 0.499 |
爱 | 积极 | 0.73 | 0.721 |
紧张 | 消极 | 0.28 | 0.276 |
乐观 | 积极 | 0.53 | 0.512 |
自豪 | 积极 | 0.30 | 0.299 |
领悟 | 积极 | 0.17 | 0.150 |
宽慰 | 积极 | 0.27 | 0.266 |
懊悔 | 消极 | 0.55 | 0.545 |
悲伤 | 消极 | 0.50 | 0.488 |
惊讶 | 中立 | 0.53 | 0.514 |
中立 | 中立 | 0.60 | 0.410 |
引用
使用本模型时,请引用相关的同行评审论文:
@article{Lalk2025EmotionDetection,
author = {Christopher Lalk and Kim Targan and Tobias Steinbrenner and Jana Schaffrath and Steffen Eberhardt and Brian Schwartz and Antonia Vehlen and Wolfgang Lutz and Julian Rubel},
title = {Employing large language models for emotion detection in psychotherapy transcripts},
journal = {Frontiers in Psychiatry},
volume = {16},
year = {2025},
doi = {10.3389/fpsyt.2025.1504306}
}
📄 许可证
本模型使用的许可证为apache - 2.0
。
Distilbert Base Uncased Finetuned Sst 2 English
Apache-2.0
基于DistilBERT-base-uncased在SST-2情感分析数据集上微调的文本分类模型,准确率91.3%
文本分类 英语
D
distilbert
5.2M
746
Xlm Roberta Base Language Detection
MIT
基于XLM-RoBERTa的多语言检测模型,支持20种语言的文本分类
文本分类
Transformers 支持多种语言

X
papluca
2.7M
333
Roberta Hate Speech Dynabench R4 Target
该模型通过动态生成数据集来改进在线仇恨检测,专注于从最差案例中学习以提高检测效果。
文本分类
Transformers 英语

R
facebook
2.0M
80
Bert Base Multilingual Uncased Sentiment
MIT
基于bert-base-multilingual-uncased微调的多语言情感分析模型,支持6种语言的商品评论情感分析
文本分类 支持多种语言
B
nlptown
1.8M
371
Emotion English Distilroberta Base
基于DistilRoBERTa-base微调的英文文本情感分类模型,可预测埃克曼六种基本情绪及中性类别。
文本分类
Transformers 英语

E
j-hartmann
1.1M
402
Robertuito Sentiment Analysis
基于RoBERTuito的西班牙语推文情感分析模型,支持POS(积极)/NEG(消极)/NEU(中性)三类情感分类
文本分类 西班牙语
R
pysentimiento
1.0M
88
Finbert Tone
FinBERT是一款基于金融通讯文本预训练的BERT模型,专注于金融自然语言处理领域。finbert-tone是其微调版本,用于金融情感分析任务。
文本分类
Transformers 英语

F
yiyanghkust
998.46k
178
Roberta Base Go Emotions
MIT
基于RoBERTa-base的多标签情感分类模型,在go_emotions数据集上训练,支持28种情感标签识别。
文本分类
Transformers 英语

R
SamLowe
848.12k
565
Xlm Emo T
XLM-EMO是一个基于XLM-T模型微调的多语言情感分析模型,支持19种语言,专门针对社交媒体文本的情感预测。
文本分类
Transformers 其他

X
MilaNLProc
692.30k
7
Deberta V3 Base Mnli Fever Anli
MIT
基于MultiNLI、Fever-NLI和ANLI数据集训练的DeBERTa-v3模型,擅长零样本分类和自然语言推理任务
文本分类
Transformers 英语

D
MoritzLaurer
613.93k
204
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98