🚀 ゴーエモーションデータセットでファインチューニングされたBERT
このモデルは、マルチラベル感情分類のためにGoEmotionsデータセットでBERT (bert-base-uncased
) をファインチューニングしたものです。入力テキストごとに複数の感情を予測することができます。
🚀 クイックスタート
モデルの概要
このモデルは、GoEmotionsデータセットで多ラベル感情分類のためにBERT (bert-base-uncased
) をファインチューニングしたバージョンです。入力テキストごとに複数の感情を予測することができます。
性能
指標 |
スコア |
Accuracy |
46.57% |
F1 Score |
56.41% |
Hamming Loss |
3.39% |
💻 使用例
基本的な使用法
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "codewithdark/bert-Gomotions"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
emotion_labels = [
"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"
]
text = "I'm so happy today!"
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.sigmoid(outputs.logits).squeeze(0)
top5_indices = torch.argsort(probs, descending=True)[:5]
top5_labels = [emotion_labels[i] for i in top5_indices]
top5_probs = [probs[i].item() for i in top5_indices]
print("Top 5 Predicted Emotions:")
for label, prob in zip(top5_labels, top5_probs):
print(f"{label}: {prob:.4f}")
'''
output:
Top 5 Predicted Emotions:
Joy: 0.9478
Love: 0.7854
Optimism: 0.6342
Admiration: 0.5678
Excitement: 0.5231
'''
高度な使用法
from transformers import pipeline
classifier = pipeline("text-classification", model="codewithdark/bert-Gomotions", top_k=None)
classifier("I'm so excited about the trip!")
🔧 技術詳細
- モデル:
bert-base-uncased
- データセット: GoEmotions
- オプティマイザ: AdamW
- 損失関数: BCEWithLogitsLoss (多ラベル分類のためのBinary Cross-Entropy)
- バッチサイズ: 16
- エポック数: 3
- 評価指標: Accuracy, F1 Score, Hamming Loss
📄 ライセンス
このモデルはApache-2.0ライセンスの下で提供されています。
🛠️ 引用
このモデルを使用する場合は、以下のように引用してください。
@misc{your_model,
author = {codewithdark},
title = {Fine-tuned BERT on GoEmotions},
year = {2025},
url = {https://huggingface.co/codewithdark/bert-Gomotions}
}