File size: 7,452 Bytes
515f4a8 962017a 515f4a8 65e4f6e 962017a 515f4a8 962017a 515f4a8 962017a 7c2bd12 962017a 7c2bd12 8139bfa 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 776bec5 962017a 7c2bd12 776bec5 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 b6df1fc 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 124ce0e 7c2bd12 962017a 7c2bd12 776bec5 962017a 776bec5 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 776bec5 7c2bd12 962017a 776bec5 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 b6df1fc 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 776bec5 7c2bd12 962017a 776bec5 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a 7c2bd12 962017a |
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
---
language:
- ja
license: apache-2.0
base_model: tohoku-nlp/bert-base-japanese-v3
library_name: transformers
pipeline_tag: text-classification
tags:
- text-classification
- toxicity-detection
- japanese
- bert
- fine-tuned
datasets:
- inspection-ai/japanese-toxic-dataset
metrics:
- accuracy
- f1
- precision
- recall
model-index:
- name: KAi-Toxicity-Filter
results:
- task:
type: text-classification
name: Text Classification
dataset:
name: japanese-toxic-dataset
type: inspection-ai/japanese-toxic-dataset
split: validation
metrics:
- type: accuracy
value: 0.8632
name: Accuracy
- type: f1
value: 0.7068
name: F1 Score
- type: precision
value: 0.7231
name: Precision
- type: recall
value: 0.6912
name: Recall
---
# KAi Toxicity Filter
日本語の有害表現検出に特化したモデル
Japanese toxicity detection model specialized for Japanese language
---
## 日本語版
### モデル概要
日本語テキストを有害/非有害に分類するモデルです。このモデルは`tohoku-nlp/bert-base-japanese-v3`をベースに、日本語の有害表現検出タスクでファインチューニングされています。
### 学習データ
以下のデータで学習されています:
- **inspection-ai/japanese-toxic-dataset** (Apache 2.0)
- 出典: https://github.com/inspection-ai/japanese-toxic-dataset
- **KAi専用カスタムデータセット**
- **自動生成されたハードネガティブサンプル**
- **自動生成された有害表現バリエーション**(バランス調整用)
### モデル詳細
- **ベースモデル**: tohoku-nlp/bert-base-japanese-v3
- **タスク**: 二値分類(有害/非有害)
- **学習手法**: 連続値ラベル学習(0.0〜1.0)+ MSE Loss
- **訓練データ**: 1,899サンプル(訓練: 1,614 / 検証: 285)
- **エポック数**: 5
- **学習率**: 2e-5(線形減衰)
- **特徴**: ハードネガティブサンプリングによる日本語表現の最適化
### 性能
検証データセットでの評価結果:
- **Accuracy**: 86.32%
- **F1 Score**: 70.68%
- **Precision**: 72.31%
- **Recall**: 69.12%
### 使用例
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "b4c0n/KAi-Toxicity-Filter"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
text = "終わってる暴言"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
toxic_prob = probs[0][1].item()
print(f"有害確率: {toxic_prob:.2%}")
```
### 使用目的
KAi (かい鯖グループAI) における日本語テキストの有害コンテンツ検出・フィルタリングのために開発されました。
**主な用途:**
- ユーザー生成コンテンツのモデレーション
- 対話型AIの安全性フィルタリング
- 日本語ソーシャルメディアコンテンツの有害性検出
### 制限事項
- 短い口語表現に特化しており、長文や文脈依存の有害性検出には限界があります
- 誤検出(偽陽性/偽陰性)の可能性があります
- 文化的・地域的文脈により判定が変わる可能性があります
- 訓練データに含まれない新しいタイプの有害表現は検出できない場合があります
- 人間のレビューなしの自動検閲には適していません
### 倫理的配慮
⚠️ このモデルは有害コンテンツデータで学習されています。責任を持って使用してください。
- 正当な表現を誤検出する可能性があります
- コンテンツ削除の唯一の判断基準として使用すべきではありません
- 定期的な人間によるレビューを推奨します
- 自動フィルタリング実装時は表現の自由を考慮してください
### ライセンス
Apache 2.0
### 謝辞
このモデルは [inspection-ai/japanese-toxic-dataset](https://github.com/inspection-ai/japanese-toxic-dataset) (Apache 2.0 License) のデータを使用しています。
---
## English
### Model Description
This model classifies Japanese text as toxic or non-toxic. It is fine-tuned from **tohoku-nlp/bert-base-japanese-v3** for Japanese toxicity detection tasks.
### Training Data
This model was trained on:
- **inspection-ai/japanese-toxic-dataset** (Apache 2.0)
- Source: https://github.com/inspection-ai/japanese-toxic-dataset
- **Custom dataset** created specifically for KAi
- **Automatically generated hard negative samples**
- **Automatically generated toxic variations** for balance
### Model Details
- **Base Model**: tohoku-nlp/bert-base-japanese-v3
- **Task**: Binary Text Classification (toxic/not-toxic)
- **Training Data**: 1,899 samples (train: 1,614 / validation: 285)
- **Epochs**: 5
- **Learning Rate**: 2e-5 with linear decay
- **Training**: Continuous label learning (0.0-1.0) with MSE Loss
- **Special Feature**: Optimized for Japanese language with hard negative sampling
### Performance
Evaluation results on validation dataset:
- **Accuracy**: 86.32%
- **F1 Score**: 70.68%
- **Precision**: 72.31%
- **Recall**: 69.12%
### Usage
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "b4c0n/KAi-Toxicity-Filter"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
text = "toxic expression"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
toxic_prob = probs[0][1].item()
print(f"Toxic probability: {toxic_prob:.2%}")
```
### Intended Use
This model was developed for the KAi (KaisabaGroupAI) to detect and filter harmful content in Japanese text.
**Primary Use Cases:**
- Content moderation for user-generated text
- Safety filtering in conversational AI
- Toxicity detection in Japanese social media content
### Limitations
- Optimized for short colloquial expressions; limited for long texts or context-dependent toxicity
- May have false positives/negatives
- Cultural and regional context may affect predictions
- Cannot detect new types of toxic expressions not present in training data
- Not designed for automatic censorship without human review
### Ethical Considerations
⚠️ This model was trained on toxic content data. Please use responsibly.
- The model may produce false positives affecting legitimate speech
- Should not be used as the sole decision-maker for content removal
- Regular human review is recommended
- Consider freedom of expression when implementing automated filtering
### License
Apache 2.0
### Citation
```bibtex
@misc{kai-toxicity-filter,
author = {b4c0n},
title = {KAi Toxicity Filter: Japanese Toxicity Detection Model},
year = {2025},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/b4c0n/KAi-Toxicity-Filter}}
}
```
### Acknowledgments
This model uses data from [inspection-ai/japanese-toxic-dataset](https://github.com/inspection-ai/japanese-toxic-dataset) (Apache 2.0 License). |