--- license: apache-2.0 language: - ja pipeline_tag: text-classification tags: - offensiveness_estimation --- # モデル概要 このモデルは、 Twitter/twhin-bert-base をSNS上のコメントに人手で攻撃性評価を行ったデータセットでFine-tuningすることで作成しました。 # Fine-tuning条件 - エポック数: 27エポック - バッチサイズ: 16 - 最大トークン長: 256 - 学習率スケジューラ: transformers.get_linear_schedule_with_warmup - ピーク学習率: 2e-5 - 最適化手法: Adam - Dropout率: 0.1 - 損失関数: MSE Loss - Re-initialize: 出力層から近い Transformer Encoder 1層 # 分類性能 **Summary** | 評価指標 | スコア | | ----- | ----- | | F値_NOT | 73.8 % | | F値_GRY | 56.8 % | | F値_OFF | 63.7 % | | マクロ平均F値 | 64.7 % | | 正解率 | 65.6 % | **Confusion matrix** | 正解ラベル \ 予測結果 | Not Offensive | Gray-area | Offensive | | ----- | ----- | ----- | ----- | | Not Offensive | 267 | 73 | 4 | | Gray-area | 105 | 173 | 42 | | Offensive | 8 | 43 | 85 | # 使い方 ```python from transformers import AutoTokenizer, AutoModelForSequenceClassification import numpy as np tokenizer = AutoTokenizer.from_pretrained("Twitter/twhin-bert-base") model = AutoModelForSequenceClassification.from_pretrained("TomokiFujihara/twhin-bert-base-japanese-offensiveness-estimation", trust_remote_code=True) inputs = tokenizer.encode_plus(text, return_tensors='pt') outputs = model(inputs['input_ids'], inputs['attention_mask']).detach().numpy()[0][:3] minimum = np.min(outputs) if minimum < 0: outputs = outputs - minimum score = outputs / np.sum(outputs) print(f'攻撃的でない発言: {score[0]:.1%},\nグレーゾーンの発言: {score[1]:.1%},\n攻撃的な発言: {score[2]:.1%}') ``` # 連絡先 E-mail: tomoki.fujihara.p3@dc.tohoku.ac.jp