概要
このモデルでは、テキスト・フラグメントに含まれる 6 種類の有害性を検出することができます。検出できる 6 種類の有害性は、「有害」、「極めて有害」、「無礼」、「脅し」、「侮辱」、「憎悪」です。基礎となるニューラル・ネットワークは、事前トレーニングされた BERT ベースの English Uncased モデルをベースに、Huggingface BERT Pytorch リポジトリー を使用した Toxic Comment Classification データセットで微調整されています。
6 種類の有害性の定義は、以下に要約されています。
Toxic: very bad, unpleasant, or harmful
Severe toxic: extremely bad and offensive
Obscene: (of the portrayal or description of sexual matters) offensive or disgusting by accepted standards of morality and decency
Threat: a statement of an intention to inflict pain, injury, damage, or other hostile action on someone in retribution for something done or not done
Insult: speak to or treat with disrespect or scornful abuse
Identity hate: hatred, hostility, or violence towards members of a race, ethnicity, nation, religion, gender, gender identity, sexual orientation or any other designated sector of society
モデルのメタデータ
ドメイン | アプリケーション | 業種 | フレームワーク | トレーニング・データ | 入力データ |
---|---|---|---|---|---|
自然言語処理 (NLP) | テキスト分類 | 一般 | PyTorch | Toxic Comment Classification データセット | テキスト |
ベンチマーク
このモデルが Kaggle Toxic Comment Classification コンペティションで達成した列ごとの ROC AUC スコアは 0.98355 (プライベート・スコア) です。この実装は、推論速度を上げるために最大文字列長を 512 ではなく 256 にしてトレーニングされています。この Kaggle コンペティションを目的としない場合、ほとんどのアプリケーションには文字列長 256 で十分すぎるほどです。
参考資料
- J.Devlin、M. Chang、K. Lee、K. Toutanova 共著「BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding」(arXiv、2018 年)
- Google BERT リポジトリー
- Huggingface BERT Pytorch リポジトリー
- 「Multi-Label Text Classification using BERT – The Mighty Transformer」
- Kaggle Toxic Comment Classification
ライセンス
コンポーネント | ライセンス | リンク |
---|---|---|
モデルの GitHub リポジトリー | Apache 2.0 | LICENSE |
微調整されたモデルの重み | Apache 2.0 | LICENSE |
事前トレーニングされたモデルの重み | Apache 2.0 | LICENSE |
TensorFlow モデルのコード (サード・パーティー) | Apache 2.0 | LICENSE |
PyTorch モデルのコード (サード・パーティー) | Apache 2.0 | LICENSE |
Toxic Comment Classification データセット | CC0 | LICENSE |
このモデルのデプロイ方法
このモデルは、以下のメカニズムを使用してデプロイできます。
- Dockerhub からデプロイする場合:
docker run -it -p 5000:5000 codait/max-toxic-comment-classifier
- Kubernetes 上にデプロイする場合:
kubectl apply -f https://raw.githubusercontent.com/IBM/MAX-Toxic-Comment-Classifier/master/max-toxic-comment-classifier.yaml
- ローカルにデプロイする場合: GitHub 上のモデルの README に記載されている手順に従います。
使用例
このモデルは cURL を使用してテストまたは使用できます。
cURL を使用してモデルをテストする
モデルをデプロイしたら、コマンド・ラインからモデルをテストできます。以下に例を示します。
curl -d "{ \"text\": [ \"I would like to punch you.\", \"In hindsight, I do apologize for my previous statement.\"]}" -X POST "http://localhost:5000/model/predict" -H "Content-Type: application/json"
以下のような JSON レスポンスが表示されるはずです。
{
"status": "ok",
"predictions": [
{
"toxic": 0.9796434044837952,
"severe_toxic": 0.07256636023521423,
"obscene": 0.058431386947631836,
"threat": 0.8635178804397583,
"insult": 0.11121545732021332,
"identity_hate": 0.013826466165482998
},
{
"toxic": 0.00029103411361575127,
"severe_toxic": 0.00012417171092238277,
"obscene": 0.0001522742968518287,
"threat": 0.00008440738747594878,
"insult": 0.00016013195272535086,
"identity_hate": 0.00012860879360232502
}
]
}