WRIME Multi-Emotion Intensity Model

日本語感情強度予測モデル

モデル概要

このモデルは、WRIMEデータセット(35,000サンプル)を用いて学習された、8種類の感情強度を同時予測するマルチタスク回帰モデルです。

ベースモデル: sbintuitions/modernbert-ja-310m

予測する8種類の感情:

  • joy (喜び)
  • sadness (悲しみ)
  • anticipation (期待)
  • surprise (驚き)
  • anger (怒り)
  • fear (恐れ)
  • disgust (嫌悪)
  • trust (信頼)

特徴

  • 複合感情検出: 複数の感情が同時に高い状態を識別可能
  • 理論最大値正規化: 感情間の相対的な強度差を保持(0-3スケールを0-1に正規化)
  • 高精度: Loss 0.005

使用方法

import torch
from transformers import AutoTokenizer

# トークナイザーとモデルを同じリポジトリから読み込み
tokenizer = AutoTokenizer.from_pretrained("MuneK/wrime-emotion-model")

# モデルの読み込み(要:モデルクラス定義)
# ※下記の「完全な使用例」を参照

# テキストの分析
text = "今日は友達と遊んで楽しかったです"
encoding = tokenizer(text, return_tensors='pt', truncation=True, max_length=512, padding='max_length')
with torch.no_grad():
    outputs = model(encoding['input_ids'], encoding['attention_mask'])
    # outputs: 8つの感情強度 (0-1スケール)

完全な使用例

モデルクラスの定義が必要です:

import torch
import torch.nn as nn
from transformers import AutoModel, AutoTokenizer

class MultiEmotionIntensityClassifier(nn.Module):
    def __init__(self, model_name="sbintuitions/modernbert-ja-310m", num_emotions=8, dropout=0.3):
        super().__init__()
        self.bert = AutoModel.from_pretrained(model_name)
        self.dropout = nn.Dropout(dropout)
        self.emotion_regressors = nn.Linear(self.bert.config.hidden_size, num_emotions)
        self.sigmoid = nn.Sigmoid()
        
    def forward(self, input_ids, attention_mask):
        outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask)
        pooled_output = outputs.last_hidden_state[:, 0]
        dropped_output = self.dropout(pooled_output)
        intensities = self.emotion_regressors(dropped_output)
        return self.sigmoid(intensities)

# モデルのロード
model = MultiEmotionIntensityClassifier()
model.load_state_dict(torch.load('pytorch_model.bin'))
model.eval()

# トークナイザー(同じリポジトリから)
tokenizer = AutoTokenizer.from_pretrained("MuneK/wrime-emotion-model")

# 予測
text = "学校に行くのが心配です"
encoding = tokenizer(text, return_tensors='pt', truncation=True, max_length=512, padding='max_length')
with torch.no_grad():
    intensities = model(encoding['input_ids'], encoding['attention_mask'])
    intensities = intensities.cpu().numpy().flatten()

emotions = ['joy', 'sadness', 'anticipation', 'surprise', 'anger', 'fear', 'disgust', 'trust']
results = dict(zip(emotions, intensities))
print(results)

性能

Overall Performance

  • Dominant Emotion Accuracy: 0.8044

Classification Report

Emotion Precision Recall F1-Score Support
joy 0.9611 0.7453 0.8395 895
sadness 0.9176 0.7091 0.8000 440
anticipation 0.7655 0.9028 0.8285 535
surprise 0.7529 0.8777 0.8105 368
anger 0.9333 0.7000 0.8000 20
fear 0.5399 0.9085 0.6773 164
disgust 0.5421 0.8406 0.6591 69
trust 0.6250 0.5556 0.5882 9
accuracy 0.8044 2500
macro avg 0.7547 0.7799 0.7504 2500
weighted avg 0.8403 0.8044 0.8091 2500

Dominant Emotion Accuracy by Class

Emotion Accuracy
joy 0.7453
sadness 0.7091
anticipation 0.9028
surprise 0.8777
anger 0.7000
fear 0.9085
disgust 0.8406
trust 0.5556

Balanced Accuracy, MCC, AUC

Metrics mean (std) min max
Balanced Acc 0.9148 (0.0436) 0.8496 0.9573
MCC 0.8754 (0.0511) 0.7811 0.9226
AUC-ROC 0.9906 (0.0056) 0.9839 0.9995

制限事項

  • 日本語テキストのみ対応

ライセンス

引用

このモデルを研究で使用される場合は、以下を引用してください:

@misc{wrime-emotion-model,
  title={WRIME Multi-Emotion Intensity Model},
  author={Muneaki Kanno},
  year={2025},
  url={https://huggingface.co/MuneK/wrime-emotion-modernbert-model}
}

@inproceedings{kajiwara2021wrime,
  title={WRIME: A New Dataset for Emotional Intensity Estimation with Subjective and Objective Annotations},
  author={Tomoyuki Kajiwara and Chenhui Chu and Noriko Takemura and Yuta Nakashima and Hajime Nagahara},
  booktitle={Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics (NAACL)},
  pages={2095--2104},
  year={2021}
}

@misc{
    modernbert-ja,
    author = {Tsukagoshi, Hayato and Li, Shengzhe and Fukuchi, Akihiko and Shibata, Tomohide},
    title = {{ModernBERT-Ja}},
    howpublished = {\url{https://huggingface.co/collections/sbintuitions/modernbert-ja-67b68fe891132877cf67aa0a}},
    url = {https://huggingface.co/collections/sbintuitions/modernbert-ja-67b68fe891132877cf67aa0a},
    year = {2025},
}

謝辞

Downloads last month
13
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support