🛡️ コメントモデレーションモデル
このモデルは、DistilBERT アーキテクチャをベースに構築された強力なマルチラベルコンテンツモデレーションシステムです。ユーザーが生成したコメント内の潜在的に有害なコンテンツを高精度に検出し、分類することができます。提供されたテキストモデレーション用のデータセットに基づくと、現時点で性能が最も優れています。さらに、最小のサイズであるため、エッジデバイスへのデプロイに最適です。現在、Hugging Face 上では、このモデルだけが、トレーニングデータに対して最小のサイズを維持しながら、このような高い性能を達成するようにトレーニングされています。

🚀 クイックスタート
Python 実装 (ローカル)
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model = AutoModelForSequenceClassification.from_pretrained("Vrandan/Comment-Moderation")
tokenizer = AutoTokenizer.from_pretrained("Vrandan/Comment-Moderation")
def analyze_text(text):
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
probabilities = outputs.logits.softmax(dim=-1).squeeze()
labels = [model.config.id2label[i] for i in range(len(probabilities))]
predictions = sorted(zip(labels, probabilities), key=lambda x: x[1], reverse=True)
return predictions
text = "Your text here"
results = analyze_text(text)
for label, prob in results:
print(f"{label}: {prob:.4f}")
出力例:
Label: OK - Probability: 0.9840
Label: H - Probability: 0.0043
Label: SH - Probability: 0.0039
Label: V - Probability: 0.0019
Label: S - Probability: 0.0018
Label: HR - Probability: 0.0015
Label: V2 - Probability: 0.0011
Label: S3 - Probability: 0.0010
Label: H2 - Probability: 0.0006
Python 実装 (サーバーレス)
import requests
API_URL = "https://api-inference.huggingface.co/models/Vrandan/Comment-Moderation"
headers = {"Authorization": "Bearer hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
output = query({
"inputs": "Your text here",
})
JavaScript 実装 (Node.js)
require('dotenv').config();
const { HfInference } = require('@huggingface/inference');
const readline = require('readline');
const hf = new HfInference(process.env.HUGGING_FACE_ACCESS_TOKEN);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
async function analyzeText(text) {
try {
const result = await hf.textClassification({
model: 'Vrandan/Comment-Moderation',
inputs: text
});
console.log('\nResults:');
result.forEach(pred => {
console.log(`Label: ${pred.label} - Probability: ${pred.score.toFixed(4)}`);
});
} catch (error) {
console.error('Error analyzing text:', error.message);
}
}
async function main() {
while (true) {
try {
const text = await new Promise(resolve => {
rl.question('\nEnter text to analyze (or "quit" to exit): ', resolve);
});
if (text.toLowerCase() === 'quit') break;
if (text.trim()) await analyzeText(text);
} catch (error) {
console.error('Error:', error.message);
}
}
rl.close();
}
main().catch(console.error);
JavaScript 実装 (サーバーレス)
async function query(data) {
const response = await fetch(
"https://api-inference.huggingface.co/models/Vrandan/Comment-Moderation",
{
headers: {
Authorization: "Bearer hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"Content-Type": "application/json",
},
method: "POST",
body: JSON.stringify(data),
}
);
const result = await response.json();
return result;
}
query({"inputs": "Your text here"}).then((response) => {
console.log(JSON.stringify(response));
});
✨ 主な機能
- マルチラベル分類
- リアルタイムのコンテンツ分析
- 95.4% の正確率
- 9 つの異なるコンテンツカテゴリ
- API またはローカル実装による簡単な統合
- 軽量なデプロイフットプリント
- エッジデバイスおよびモバイルアプリケーションに適している
- 低遅延推論
- 高精度を維持しながらリソース効率が良い
- 一般的なハードウェアで実行可能
📊 コンテンツカテゴリ
このモデルは、以下のタイプの潜在的に有害なコンテンツを識別します。
カテゴリ |
ラベル |
定義 |
性的な内容 |
S |
性的興奮を引き起こすことを目的としたコンテンツ。例えば、性行為の説明や性サービスの宣伝 (性教育や健康に関する内容を除く)。 |
憎悪的な内容 |
H |
人種、性別、民族、宗教、国籍、性的指向、障害の有無、またはカーストに基づく憎悪を表現、扇動、または促進するコンテンツ。 |
暴力的な内容 |
V |
暴力を宣伝または美化し、または他人の苦しみや屈辱を祝うコンテンツ。 |
嫌がらせ的な内容 |
HR |
現実の個人を悩ませたり、迷惑をかけたりするために使用される可能性のあるコンテンツ。 |
自傷的な内容 |
SH |
自傷行為 (自殺、切り傷、摂食障害など) を促進、奨励、または描写するコンテンツ。 |
未成年に関する性的内容 |
S3 |
18 歳未満の個人を含む性的コンテンツ。 |
憎悪的で脅威的な内容 |
H2 |
標的グループに対する暴力または深刻な危害を含む憎悪的なコンテンツ。 |
グラフィックな暴力的内容 |
V2 |
死、暴力、または深刻な身体的損傷を極めて詳細に描写する暴力的なコンテンツ。 |
安全なコンテンツ |
OK |
ガイドラインに違反しない適切なコンテンツ。 |
📊 詳細なモデル性能
このモデルは、標準的な分類指標を使用して広範に評価されています。
- 損失: 0.641
- 正確率: 0.954 (95.4%)
- マクロ F1 スコア: 0.407
- マイクロ F1 スコア: 0.802
- 加重 F1 スコア: 0.763
- マクロ精度: 0.653
- マイクロ精度: 0.875
- 加重精度: 0.838
- マクロ再現率: 0.349
- マイクロ再現率: 0.740
- 加重再現率: 0.740
- 平均 ROC AUC: 0.912
🔧 技術詳細
このモデルは、家庭用のセットアップで NVIDIA RTX 3080 GPU を使用してトレーニングされました。これは、一般的なハードウェアでも効果的なコンテンツモデレーションモデルを開発できることを示しています。これにより、個々の開発者や小規模組織にとって、モデル開発プロセスがよりアクセスしやすくなっています。
主要なトレーニング仕様:
- ハードウェア: NVIDIA RTX 3080
- ベースモデル: DistilBERT
- モデルサイズ: 67M パラメータ (効率的なデプロイのために最適化)
- トレーニング環境: ローカルワークステーション
- トレーニングタイプ: ファインチューニング
比較的コンパクトなサイズ (67M パラメータ) であるにもかかわらず、このモデルは印象的な性能指標を達成しており、さまざまなデバイスや環境にデプロイするのに適しています。モデルの効率と性能の比率は、大規模な計算リソースを必要とせずに効果的なコンテンツモデレーションが可能であることを示しています。
⚠️ 重要提示
⚠️ 重要提示
- 定期的なバイアスモニタリング
- コンテキストを考慮した実装
- プライバシーを最優先とするアプローチ
💡 使用建议
- コンテキストのニュアンスを見逃す可能性があります。
- 誤検知の可能性があります。
- 文化的なコンテキストの違いに対応できない場合があります。
📚 ドキュメント
このモデルは、OpenAI が公開したデータセットを使用してトレーニングされました。詳細は、彼らの論文 "A Holistic Approach to Undesired Content Detection" を参照してください。
データセットのソース
引用
このモデルまたはデータセットを研究で使用する場合は、以下のように引用してください。
@article{openai2022moderation,
title={A Holistic Approach to Undesired Content Detection},
author={Todor Markov and Chong Zhang and Sandhini Agarwal and Tyna Eloundou and Teddy Lee and Steven Adler and Angela Jiang and Lilian Weng},
journal={arXiv preprint arXiv:2208.03274},
year={2022}
}
📄 ライセンス
このモデルは OpenRAIL ライセンスの下で提供されています。
📧 問い合わせ
サポートや質問がある場合は、Slack でメッセージを送ってください。