🚀 bert-base-uncased-emotion
このプロジェクトは、BERTモデルを感情データセットで微調整したもので、テキストの感情分類タスクに使用できます。テキスト内の感情カテゴリを正確に識別でき、Twitter感情データセットで優れた性能を発揮します。
🚀 クイックスタート
以下のコード例を使用すると、このモデルをすぐにテキストの感情分類に使用できます。
from transformers import pipeline
classifier = pipeline("text-classification",model='bhadresh-savani/bert-base-uncased-emotion', return_all_scores=True)
prediction = classifier("I love using transformers. The best part is wide range of support and its easy to use", )
print(prediction)
"""
output:
[[
{'label': 'sadness', 'score': 0.0005138228880241513},
{'label': 'joy', 'score': 0.9972520470619202},
{'label': 'love', 'score': 0.0007443308713845909},
{'label': 'anger', 'score': 0.0007404946954920888},
{'label': 'fear', 'score': 0.00032938539516180754},
{'label': 'surprise', 'score': 0.0004197491507511586}
]]
"""
✨ 主な機能
- BERTアーキテクチャに基づく:Transformerの双方向エンコーダアーキテクチャを採用し、MLM(マスク言語モデル)ターゲットで事前学習されています。
- 微調整による最適化:感情データセットで微調整されており、テキストの感情分類タスクにより適しています。
- 多指標評価:精度やF1スコアなど、複数の評価指標で良好な結果を示します。
📦 インストール
ドキュメントに具体的なインストール手順は記載されていません。Hugging Face関連のライブラリのインストール方法を参考にしてください。
💻 使用例
基本的な使用法
from transformers import pipeline
classifier = pipeline("text-classification",model='bhadresh-savani/bert-base-uncased-emotion', return_all_scores=True)
prediction = classifier("I love using transformers. The best part is wide range of support and its easy to use", )
print(prediction)
"""
output:
[[
{'label': 'sadness', 'score': 0.0005138228880241513},
{'label': 'joy', 'score': 0.9972520470619202},
{'label': 'love', 'score': 0.0007443308713845909},
{'label': 'anger', 'score': 0.0007404946954920888},
{'label': 'fear', 'score': 0.00032938539516180754},
{'label': 'surprise', 'score': 0.0004197491507511586}
]]
"""
📚 ドキュメント
モデルの説明
Bert は、Transformerに基づく双方向エンコーダアーキテクチャで、MLM(マスク言語モデル)ターゲットで学習されています。
bert-base-uncased は、HuggingFaceのTrainerを使用して感情データセットで微調整されており、学習パラメータは以下の通りです。
学習率 2e-5,
バッチサイズ 64,
エポック数 8
Twitter感情データセットでのモデルの性能比較
データセット
Twitter-Sentiment-Analysis
学習プロセス
Colab Notebook を参考にし、モデル名をdistilbertからbertに変更するだけです。
評価結果
{
'test_accuracy': 0.9405,
'test_f1': 0.9405920712282673,
'test_loss': 0.15769127011299133,
'test_runtime': 10.5179,
'test_samples_per_second': 190.152,
'test_steps_per_second': 3.042
}
参考文献
📄 ライセンス
このプロジェクトは、Apache-2.0ライセンスの下で提供されています。