🚀 Fast Emotion-X: ファインチューニングされたDeBERTa V3 Smallベースの感情検出
Fast Emotion-Xは、最先端の感情検出モデルで、MicrosoftのDeBERTa V3 Smallモデルをファインチューニングしたものです。このモデルは、テキストを6つの感情カテゴリのいずれかに正確に分類するように設計されています。DeBERTaの強力な機能を活用し、包括的な感情データセットでファインチューニングされているため、高精度と信頼性が保証されています。
✨ 主な機能
- テキストを6つの感情カテゴリ(怒り、嫌悪、恐怖、喜び、悲しみ、驚き)に分類することができます。
- 提供されるPythonパッケージまたはHugging Faceの
transformers
ライブラリを使用して直接利用できます。
- 単一のテキストや複数のテキストを一度に分類することができます。
- 感情の分布を可視化することができます。
- コマンドラインインターフェース(CLI)を使用して操作できます。
- pandas DataFrameと統合してテキスト列を分類することができます。
- 感情のトレンドを分析して可視化することができます。
- 独自のデータセットで事前学習済みモデルをファインチューニングすることができます。
📦 インストール
pipを使用してパッケージをインストールします:
pip install emotionclassifier
💻 使用例
基本的な使用法
emotionclassifier
を使用して単一のテキストを分類する例を次に示します:
from emotionclassifier import EmotionClassifier
classifier = EmotionClassifier()
text = "I am very happy today!"
result = classifier.predict(text)
print("Emotion:", result['label'])
print("Confidence:", result['confidence'])
バッチ処理
predict_batch
メソッドを使用して複数のテキストを一度に分類することができます:
texts = ["I am very happy today!", "I am so sad."]
results = classifier.predict_batch(texts)
print("Batch processing results:", results)
可視化
テキストの感情分布を可視化するには:
from emotionclassifier import plot_emotion_distribution
result = classifier.predict("I am very happy today!")
plot_emotion_distribution(result['probabilities'], classifier.labels.values())
コマンドラインインターフェース(CLI)の使用
コマンドラインからパッケージを使用することもできます:
emotionclassifier --model deberta-v3-small --text "I am very happy today!"
DataFrameとの統合
pandas DataFrameと統合してテキスト列を分類することができます:
import pandas as pd
from emotionclassifier import DataFrameEmotionClassifier
df = pd.DataFrame({
'text': ["I am very happy today!", "I am so sad."]
})
classifier = DataFrameEmotionClassifier()
df = classifier.classify_dataframe(df, 'text')
print(df)
感情トレンドの分析
感情のトレンドを分析して可視化することができます:
from emotionclassifier import EmotionTrends
texts = ["I am very happy today!", "I am feeling okay.", "I am very sad."]
trends = EmotionTrends()
emotions = trends.analyze_trends(texts)
trends.plot_trends(emotions)
ファインチューニング
独自のデータセットで事前学習済みモデルをファインチューニングすることができます:
from emotionclassifier.fine_tune import fine_tune_model
train_dataset = ...
val_dataset = ...
fine_tune_model(classifier.model, classifier.tokenizer, train_dataset, val_dataset, output_dir='fine_tuned_model')
transformersライブラリの使用
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model_name = "AnkitAI/deberta-v3-small-base-emotions-classifier"
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
def predict_emotion(text):
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
outputs = model(**inputs)
logits = outputs.logits
predictions = logits.argmax(dim=1)
return predictions
text = "I'm so happy with the results!"
emotion = predict_emotion(text)
print("Detected Emotion:", emotion)
🔧 技術詳細
モデルの詳細
プロパティ |
詳細 |
モデル名 |
AnkitAI/deberta-v3-small-base-emotions-classifier |
ベースモデル |
microsoft/deberta-v3-small |
データセット |
dair-ai/emotion |
ファインチューニング |
感情検出のためにファインチューニングされ、怒り、嫌悪、恐怖、喜び、悲しみ、驚きの6つの感情カテゴリの分類ヘッドがあります。 |
トレーニングの詳細
モデルは以下のパラメータを使用してトレーニングされました:
- 学習率: 2e-5
- バッチサイズ: 4
- 重み減衰: 0.01
- 評価戦略: エポック
トレーニングの詳細情報
- 評価損失: 0.0858
- 評価実行時間: 110070.6349秒
- 評価サンプル/秒: 78.495
- 評価ステップ/秒: 2.453
- トレーニング損失: 0.1049
- 評価精度: 94.6%
- 評価適合率: 94.8%
- 評価再現率: 94.5%
- 評価F1スコア: 94.7%
📄 ライセンス
このモデルはMITライセンスの下でライセンスされています。