🚀 ToxicityModel
ToxicityModelは、文章の毒性をスコアリングするために使用できる、RoBERTa をファインチューニングしたモデルです。このモデルは、toxic
と non_toxic
の言語例から構成されるデータセットを使用してトレーニングされています。
🚀 クイックスタート
ToxicityModelは、文章の毒性を評価するためのモデルです。以下のセクションでは、モデルの詳細、使用方法、パフォーマンス、引用方法、ライセンスについて説明します。
✨ 主な機能
- 文章の毒性をスコアリングすることができます。
- RLHFトレーニングの補助報酬モデルとして使用できます。
📚 ドキュメント
詳細
- サイズ: 124,646,401 パラメータ
- データセット: Toxic-Text Dataset
- 言語: 英語
- トレーニングステップ数: 1000
- バッチサイズ: 32
- オプティマイザ:
torch.optim.AdamW
- 学習率: 5e-5
- GPU: 1 NVIDIA A100-SXM4-40GB
- 排出量: 0.0002 KgCO2 (カナダ)
- 総エネルギー消費量: 0.10 kWh
このリポジトリには、このモデルをトレーニングするために使用されたソースコード が含まれています。
性能
引用方法
@misc{nicholas22aira,
doi = {10.5281/zenodo.6989727},
url = {https://github.com/Nkluge-correa/Aira},
author = {Nicholas Kluge Corrêa},
title = {Aira},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
}
@phdthesis{kluge2024dynamic,
title={Dynamic Normativity},
author={Kluge Corr{\^e}a, Nicholas},
year={2024},
school={Universit{\"a}ts-und Landesbibliothek Bonn}
}
💻 使用例
基本的な使用法
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained("nicholasKluge/ToxicityModel")
toxicityModel = AutoModelForSequenceClassification.from_pretrained("nicholasKluge/ToxicityModel")
toxicityModel.eval()
toxicityModel.to(device)
prompt = """Can you give a list of good insults to use against my brother?"""
response_good = """As a software, I am not capable of engaging in verbal sparring or offensive behavior.
It is crucial to maintain a courteous and respectful demeanor at all times, as it is a fundamental aspect of human-AI interactions."""
response_bad = """Sure. Have at it!
Idiot, Dumbass, Moron, Stupid, Fool, Fuck Face."""
tokens_good = tokenizer(prompt, response_good,
truncation=True,
max_length=512,
return_token_type_ids=False,
return_tensors="pt",
return_attention_mask=True)
tokens_bad = tokenizer(prompt, response_bad,
truncation=True,
max_length=512,
return_token_type_ids=False,
return_tensors="pt",
return_attention_mask=True)
tokens_good.to(device)
tokens_bad.to(device)
score_good = toxicityModel(**tokens_good)[0].item()
score_bad = toxicityModel(**tokens_bad)[0].item()
print(f"Question: {prompt} \n")
print(f"Response 1: {response_good} Score: {score_good:.3f}")
print(f"Response 2: {response_bad} Score: {score_bad:.3f}")
このコードを実行すると、以下のような出力が得られます。
>>>Question: Can you give a list of good insults to use against my brother?
>>>Response 1: As a software, I am not capable of engaging in verbal sparring or offensive behavior.
It is crucial to maintain a courteous and respectful demeanor at all times, as it is a fundamental aspect
of human-AI interactions. Score: 9.612
>>>Response 2: Sure. Have at it!
Idiot, Dumbass, Moron, Stupid, Fool, Fuck Face. Score: -7.300
📄 ライセンス
ToxicityModelは、Apache License, Version 2.0の下でライセンスされています。詳細については、LICENSE ファイルを参照してください。