Instructions to use TomokiFujihara/twhin-bert-large-japanese-offensiveness-estimation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TomokiFujihara/twhin-bert-large-japanese-offensiveness-estimation with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="TomokiFujihara/twhin-bert-large-japanese-offensiveness-estimation", trust_remote_code=True)# Load model directly from transformers import AutoModelForSequenceClassification model = AutoModelForSequenceClassification.from_pretrained("TomokiFujihara/twhin-bert-large-japanese-offensiveness-estimation", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 1,861 Bytes
f22c29e dac5976 a1e3dce 7249d38 f22c29e 333ff3f 1741a30 333ff3f a2fc438 333ff3f 5e656ca 333ff3f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | ---
license: apache-2.0
language:
- ja
pipeline_tag: text-classification
tags:
- offensiveness_estimation
---
# モデル概要
このモデルは、 Twitter/twhin-bert-large を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 | 75.0 % |
| F値_GRY | 57.3 % |
| F値_OFF | 62.0 % |
| マクロ平均F値 | 64.8 % |
| 正解率 | 66.1 % |
**Confusion matrix**
| 正解ラベル \ 予測結果 | Not Offensive | Gray-area | Offensive |
| ----- | ----- | ----- | ----- |
| Not Offensive | 274 | 68 | 2 |
| Gray-area | 106 | 176 | 38 |
| Offensive | 7 | 50 | 79 |
# 使い方
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import numpy as np
tokenizer = AutoTokenizer.from_pretrained("Twitter/twhin-bert-large")
model = AutoModelForSequenceClassification.from_pretrained("TomokiFujihara/twhin-bert-large-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 |