🚀 德语有毒评论分类
本项目的模型用于检测德语评论中的有毒或潜在有害内容,通过在多个德语数据集上微调预训练模型,实现对评论毒性的分类。
🔍 内容检测与章节生成
经过对原文档的扫描,发现文档包含模型描述、预期用途与限制、使用方法、局限性和偏差、训练数据、训练过程、评估结果等实质内容,将按照对应模板生成美化后的文档。
🚀 快速开始
模型使用示例
from transformers import pipeline
model_hub_url = 'https://huggingface.co/ml6team/distilbert-base-german-cased-toxic-comments'
model_name = 'ml6team/distilbert-base-german-cased-toxic-comments'
toxicity_pipeline = pipeline('text-classification', model=model_name, tokenizer=model_name)
comment = "Ein harmloses Beispiel"
result = toxicity_pipeline(comment)[0]
print(f"Comment: {comment}\nLabel: {result['label']}, score: {result['score']}")
✨ 主要特性
- 针对性强:专门针对德语评论进行毒性检测。
- 多数据集训练:在多个德语数据集上进行微调,提高检测的准确性。
📦 安装指南
原文档未提及具体安装步骤,跳过此章节。
💻 使用示例
基础用法
from transformers import pipeline
model_hub_url = 'https://huggingface.co/ml6team/distilbert-base-german-cased-toxic-comments'
model_name = 'ml6team/distilbert-base-german-cased-toxic-comments'
toxicity_pipeline = pipeline('text-classification', model=model_name, tokenizer=model_name)
comment = "Ein harmloses Beispiel"
result = toxicity_pipeline(comment)[0]
print(f"Comment: {comment}\nLabel: {result['label']}, score: {result['score']}")
📚 详细文档
模型描述
该模型旨在检测有毒或潜在有害的评论。我们在包含毒性、亵渎、冒犯或仇恨言论的五个德语数据集的组合上,对德语DistilBERT模型 distilbert-base-german-cased 进行了微调。
预期用途与限制
此模型可用于检测德语评论中的毒性。然而,毒性的定义较为模糊,模型可能无法检测到所有的毒性情况。并且,该模型只能检测德语评论中的毒性,无法处理其他语言。
局限性和偏差
模型在包含来自不同社交网络和互联网社区示例的数据集组合上进行训练,这仅代表了可能的毒性实例的一小部分,其他领域的实例可能无法被可靠检测。
🔧 技术细节
训练数据
训练数据集结合了以下五个数据集:
- GermEval18 [数据集]
- GermEval21 [数据集]
- IWG仇恨言论数据集 [论文, 数据集]
- 2017年Breitschneider和Peters的社交媒体中针对外国人的冒犯性言论检测 [数据集]
- HASOC:2019年仇恨言论和冒犯性内容 [数据集]
这些数据集包含从亵渎到仇恨言论再到毒性的不同标签。在组合数据集中,这些标签被归纳为 有毒
和 无毒
,总共包含23,515个示例。需要注意的是,这些数据集的示例数量差异很大。
训练过程
训练集和测试集的创建方式为:如果有预定义的训练/测试分割,则使用该分割;否则,使用80%的示例进行训练,20%进行测试。最终得到17,072个训练示例和6,443个测试示例。
模型训练了2个周期,使用以下参数:
training_args = TrainingArguments(
per_device_train_batch_size=batch_size,
per_device_eval_batch_size=batch_size,
num_train_epochs=2,
evaluation_strategy="steps",
logging_strategy="steps",
logging_steps=100,
save_total_limit=5,
learning_rate=2e-5,
weight_decay=0.01,
metric_for_best_model='accuracy',
load_best_model_at_end=True
)
评估结果
模型评估在数据集的1/10上进行,该部分作为测试数据集。
准确率 |
F1分数 |
召回率 |
精确率 |
78.50 |
50.34 |
39.22 |
70.27 |
📄 许可证
原文档未提及许可证信息,跳过此章节。