dair-ai/emotion
Viewer • Updated • 437k • 33k • 492
How to use SXNNNN/distilbert-emotion-hw2 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="SXNNNN/distilbert-emotion-hw2") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("SXNNNN/distilbert-emotion-hw2")
model = AutoModelForSequenceClassification.from_pretrained("SXNNNN/distilbert-emotion-hw2", device_map="auto")《人工智能基础》大作业 2:英文短文本情绪识别(6 类)。
在 distilbert-base-uncased 上以 5e-5 学习率、5 个 epoch、batch size 8、最大长度 128 微调,数据为 emotion 数据集(train 16000 / validation 2000 / test 2000)。
sadness, joy, love, anger, fear, surprise(id2label 已写入 config.json)。
| 划分 | Accuracy | Macro-F1 |
|---|---|---|
| Validation | 94.45% | 94.45% |
| Test | 92.85% | 92.85% |
多数类基线为 35.20%。同任务下 TF-IDF + Logistic Regression 为 63.45%,LinearSVC 为 62.90%,RandomForest 为 52.45%,效果明显低于微调模型。
各类别在验证集上的表现:sadness F1 0.971、joy 0.958、love 0.874、anger 0.945、fear 0.920、surprise 0.863。主要错误集中在 joy 与 love 混淆(21 条)、anger 被判为 sadness(8 条)。
from transformers import pipeline
clf = pipeline("text-classification", model="SXNNNN/distilbert-emotion-hw2")
print(clf("i feel so blessed and grateful today"))
Base model
distilbert/distilbert-base-uncased