🚀 bert-43-多标签情感检测模型
本模型旨在解决英文文本情感内容理解和分类的问题,可对英文句子的情感内容进行分类,为情感分析、社交媒体监测等应用提供支持。
🚀 快速开始
你可以按照以下代码示例快速使用该模型:
from transformers import pipeline
model = 'borisn70/bert-43-multilabel-emotion-detection'
tokenizer = 'borisn70/bert-43-multilabel-emotion-detection'
nlp = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
result = nlp("I feel great about this!")
print(result)
✨ 主要特性
- 基于“bert-base-uncased”进行微调,可将英文句子的情感内容分为43个类别。
- 在多个数据集上进行训练,包括
tweet_emotions
、GoEmotions
和合成数据。
- 在验证集上取得了较高的性能指标,如准确率达到92.02%。
📦 安装指南
文档未提及具体安装命令,暂不提供安装指南。
💻 使用示例
基础用法
from transformers import pipeline
model = 'borisn70/bert-43-multilabel-emotion-detection'
tokenizer = 'borisn70/bert-43-multilabel-emotion-detection'
nlp = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
result = nlp("I feel great about this!")
print(result)
📚 详细文档
模型描述
“bert-43-多标签情感检测”模型是“bert-base-uncased”的微调版本,经过训练,可根据英文句子的情感内容将其分为43个类别之一。该模型在多个数据集的组合上进行训练,包括tweet_emotions
、GoEmotions
和合成数据,总计约271,000条记录,每个标签约有6,306条记录。
预期用途
该模型适用于任何需要理解或分类英文文本情感内容的应用,包括情感分析、社交媒体监测、客户反馈分析等。
训练数据
训练数据包括以下数据集:
- Tweet Emotions
- GoEmotions
- 合成数据
训练过程
该模型在Google Colab V100 GPU(16 GB RAM)上训练了20个epoch,大约耗时6小时。使用了以下设置:
from transformers import TrainingArguments
training_args = TrainingArguments(
output_dir='results',
optim="adamw_torch",
learning_rate=2e-5,
num_train_epochs=20,
per_device_train_batch_size=128,
per_device_eval_batch_size=128,
warmup_steps=500,
weight_decay=0.01,
logging_dir='./logs',
logging_steps=100,
)
性能
该模型在验证集上取得了以下性能指标:
- 准确率:92.02%
- 加权F1分数:91.93%
- 加权精确率:91.88%
- 加权召回率:92.02%
同时还提供了43个标签中每个标签的详细性能信息。
标签映射
标签ID |
情感 |
0 |
钦佩 |
1 |
愉悦 |
2 |
愤怒 |
3 |
恼怒 |
4 |
认可 |
5 |
关怀 |
6 |
困惑 |
7 |
好奇 |
8 |
渴望 |
9 |
失望 |
10 |
不认可 |
11 |
厌恶 |
12 |
尴尬 |
13 |
兴奋 |
14 |
恐惧 |
15 |
感激 |
16 |
悲痛 |
17 |
喜悦 |
18 |
爱 |
19 |
紧张 |
20 |
乐观 |
21 |
骄傲 |
22 |
领悟 |
23 |
宽慰 |
24 |
懊悔 |
25 |
悲伤 |
26 |
惊讶 |
27 |
中立 |
28 |
担忧 |
29 |
幸福 |
30 |
乐趣 |
31 |
仇恨 |
32 |
自主 |
33 |
安全 |
34 |
理解 |
35 |
空虚 |
36 |
热情 |
37 |
消遣 |
38 |
归属感 |
39 |
意义 |
40 |
维持 |
41 |
创造力 |
42 |
无聊 |
准确率报告
标签 |
精确率 |
召回率 |
F1分数 |
0 |
0.8625 |
0.7969 |
0.8284 |
1 |
0.9128 |
0.9558 |
0.9338 |
2 |
0.9028 |
0.8749 |
0.8886 |
3 |
0.8570 |
0.8639 |
0.8605 |
4 |
0.8584 |
0.8449 |
0.8516 |
5 |
0.9343 |
0.9667 |
0.9502 |
6 |
0.9492 |
0.9696 |
0.9593 |
7 |
0.9234 |
0.9462 |
0.9347 |
8 |
0.9644 |
0.9924 |
0.9782 |
9 |
0.9481 |
0.9377 |
0.9428 |
10 |
0.9250 |
0.9267 |
0.9259 |
11 |
0.9653 |
0.9914 |
0.9782 |
12 |
0.9948 |
0.9976 |
0.9962 |
13 |
0.9474 |
0.9676 |
0.9574 |
14 |
0.8926 |
0.8853 |
0.8889 |
15 |
0.9501 |
0.9515 |
0.9508 |
16 |
0.9976 |
0.9990 |
0.9983 |
17 |
0.9114 |
0.8716 |
0.8911 |
18 |
0.7825 |
0.7821 |
0.7823 |
19 |
0.9962 |
0.9990 |
0.9976 |
20 |
0.9516 |
0.9638 |
0.9577 |
21 |
0.9953 |
0.9995 |
0.9974 |
22 |
0.9630 |
0.9791 |
0.9710 |
23 |
0.9134 |
0.9134 |
0.9134 |
24 |
0.9753 |
0.9948 |
0.9849 |
25 |
0.7374 |
0.7469 |
0.7421 |
26 |
0.7864 |
0.7583 |
0.7721 |
27 |
0.6000 |
0.5666 |
0.5828 |
28 |
0.7369 |
0.6836 |
0.7093 |
29 |
0.8066 |
0.7222 |
0.7620 |
30 |
0.9116 |
0.9225 |
0.9170 |
31 |
0.9108 |
0.9524 |
0.9312 |
32 |
0.9611 |
0.9634 |
0.9622 |
33 |
0.9592 |
0.9724 |
0.9657 |
34 |
0.9700 |
0.9686 |
0.9693 |
35 |
0.9459 |
0.9734 |
0.9594 |
36 |
0.9359 |
0.9857 |
0.9601 |
37 |
0.9986 |
0.9986 |
0.9986 |
38 |
0.9943 |
0.9990 |
0.9967 |
39 |
0.9990 |
1.0000 |
0.9995 |
40 |
0.9905 |
0.9914 |
0.9910 |
41 |
0.9981 |
0.9948 |
0.9964 |
42 |
0.9929 |
0.9986 |
0.9957 |
加权平均 |
0.9188 |
0.9202 |
0.9193 |
局限性和偏差
⚠️ 重要提示
- 模型在不同情感类别上的性能可能会有显著差异,尤其是在训练数据中代表性较少的类别。
- 用户应谨慎对待训练数据中可能存在的偏差,这些偏差可能会反映在模型的预测中。
联系信息
如果你有任何问题、反馈或想报告模型的任何问题,请随时联系:
📄 许可证
本模型采用MIT许可证。