🚀 ModernBERT-base情感分类模型
该模型基于Transformer架构,在Super Emotion数据集上对ModernBERT-base进行微调,用于多类别情感分类。它能够预测文本中的七种情感状态,包括喜悦、悲伤、愤怒、恐惧、爱、中立和惊讶。
🚀 快速开始
本模型可用于英文文本的情感分类任务,适用于社交媒体情感分析、客户反馈评估以及大规模行为或心理研究等场景。
✨ 主要特性
- 基于ModernBERT-base模型进行微调,在Super Emotion数据集上训练。
- 可预测七种情感状态:
喜悦、悲伤、愤怒、恐惧、爱、中立、惊讶
。
- 使用Hugging Face Transformers框架进行微调。
📦 安装指南
暂未提及具体安装步骤,可参考Hugging Face Transformers库的安装文档。
💻 使用示例
基础用法
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="cirimus/modernbert-base-emotions",
top_k=5
)
text = "I can't believe this just happened!"
predictions = classifier(text)
sorted_preds = sorted(predictions[0], key=lambda x: x['score'], reverse=True)
top_3 = sorted_preds[:3]
print("\nTop 3 emotions detected:")
for pred in top_3:
print(f"\t{pred['label']:10s} : {pred['score']:.3f}")
📚 详细文档
模型详情
模型创建方式
该模型使用以下超参数进行了2个epoch的微调:
- 学习率:
2e-5
- 批次大小:16
- 权重衰减:
0.01
- 预热步骤:余弦衰减调度
- 优化器:AdamW
- 评估指标:精确率、召回率、F1分数(宏平均)、准确率
评估结果
在联合测试集上的评估结果如下:
|
准确率 |
精确率 |
召回率 |
F1分数 |
MCC |
支持样本数 |
宏平均 |
0.872 |
0.827 |
0.850 |
0.836 |
0.840 |
56310 |
中立 |
0.965 |
0.711 |
0.842 |
0.771 |
0.755 |
3907 |
惊讶 |
0.976 |
0.693 |
0.772 |
0.730 |
0.719 |
2374 |
恐惧 |
0.975 |
0.897 |
0.841 |
0.868 |
0.855 |
5608 |
悲伤 |
0.960 |
0.910 |
0.937 |
0.923 |
0.896 |
14547 |
喜悦 |
0.941 |
0.933 |
0.872 |
0.902 |
0.861 |
17328 |
愤怒 |
0.964 |
0.912 |
0.818 |
0.862 |
0.843 |
7793 |
爱 |
0.962 |
0.734 |
0.867 |
0.795 |
0.778 |
4753 |

预期用途
该模型专为英文文本的情感分类而设计,特别适用于以下场景:
- 社交媒体情感分析
- 客户反馈评估
- 大规模行为或心理研究
不过,该模型在处理微妙表达或间接提及情感的文本时可能表现不佳,例如:"I find myself remembering the little things you say, long after you've said them."
局限性和偏差
- 数据偏差:数据集来自多个来源,可能在标注和类别分布上存在偏差。
- 类别样本不均衡:某些情感的样本较少,影响了其分类性能。
- 上下文依赖:该模型对单个句子进行分类,在多句子上下文中可能表现不佳。
环境影响
📄 许可证
本模型使用CC-BY-4.0许可证。
引用
如果您使用此模型,请引用:
@inproceedings{JdFE2025b,
title = {Emotion Classification with ModernBERT},
author = {Enric Junqu\'e de Fortuny},
year = {2025},
howpublished = {\url{https://huggingface.co/your_model_name_here}},
}