
基于RoBERTa的毒性检测与评分优化工具
这是一款基于RoBERTa的微调模型,用于有效检测和评分文本毒性。模型通过有毒及无毒语言示例训练,特别在wiki_toxic和toxic_conversations_50k数据集上表现出色。作为RLHF训练的辅助工具,该模型的输出值可用于判断文本的毒性与否,适合多种需检测有毒语言的应用场景。
ToxicityModel 是一种经过微调的模型,基于 RoBERTa 开发,用于评估句子的毒性程度。此模型通过包含“有毒”和“无毒”语言示例的数据集进行训练,旨在帮助识别和筛选文本中的潜在有害内容。
torch.optim.AdamW此模型的源代码可以在 GitHub 仓库中找到:Aira。
ToxicityModel 可以用作强化学习人类反馈(RLHF)训练中的辅助奖励模型。负值(数值越接近0)表示文本中存在毒性,而正值(数值越接近1)表示文本无毒性。
以下是ToxicityModel用来评估文本毒性程度的示例代码:
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.\n\nIt 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!\n\nIdiot, 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
| 准确率 | wiki_toxic | toxic_conversations_50k |
|---|---|---|
| Aira-ToxicityModel | 92.05% | 91.63% |
ToxicityModel 遵循 Apache 2.0 许可证。浏览 LICENSE 文件获取更多信息。


全球首个AI音乐社区
音述AI是全球首个AI音乐社区,致力让每个人都能用音乐表达自我。音述AI提供零门槛AI创作工具,独创GETI法则帮助用户精准定义音乐风格,AI润色功能支持自动优化作品质感。音述AI支持交流讨论、二次创作与价值变现。针对中文用户的语言习惯与文化背景进行专门优化,支持国风融合、C-pop等本土音乐标签,让技术更好地承载人文表达。


一站式搞定所有学习需求
不再被海量信息淹没,开始真正理解知识。Lynote 可摘要 YouTube 视频、PDF、文章等内容。即时创建笔记,检测 AI 内容并下载资料,将您的学习效率提升 10 倍。


为AI短剧协作而生
专为AI短剧协作而生的AniShort正式发布,深度重构AI短剧全流程生产模式,整合创意策划、制作执行、实时协作、在线审片、资产复用等全链路功能,独创无限画布、双轨并行工业化工作流与Ani智能体助手,集成多款主流AI大模型,破解素材零散、版本混乱、沟通低效等行业痛点,助力3人团队效率提升800%,打造标准化、可追溯的AI短剧量产体系,是AI短剧团队协同创作、提升制作效率的核心工具。


能听懂你表达的视频模 型
Seedance two是基于seedance2.0的中国大模型,支持图像、视频、音频、文本四种模态输入,表达方式更丰富,生成也更可控。


国内直接访问,限时3折
输入简单文字,生成想要的图片,纳米香蕉中文站基于 Google 模型的 AI 图片生成网站,支持文字生图、图生图。官网价格限时3折活动


职场AI,就用扣子
AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!

