🚀 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}},
}