arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2408.11727cs.CRcs.AIcs.CLcs.SE
收藏

大语言模型中有害提示的高效检测

Efficient Detection of Toxic Prompts in Large Language Models

Nanyang Technological University(南洋理工大学);ShanghaiTech University(上海科技大学)

Yi Liu, Junzhe Yu, Huijia Sun, Ling Shi, Gelei Deng, Yuqi Chen, Yang Liu

AI总结:

针对现有大语言模型有害提示检测技术在多样性、效率等方面的不足,提出轻量级灰盒方法 ToxicDetector,通过生成有害概念提示、嵌入向量建特征和 MLP 分类实现检测,准确率高、速度快,适用于实时场景。

摘要:

ChatGPT、Gemini 等大语言模型(LLM)极大推动了自然语言处理的发展,支撑了聊天机器人、自动化内容生成等各类应用。然而,恶意人员可通过构造有害提示诱导模型生成有害或违背伦理的回复,还常使用越狱技术绕过安全机制,因此亟需鲁棒的有害提示检测方法。现有黑盒、白盒检测技术在有害提示多样性、可扩展性和计算效率方面存在挑战。对此,我们提出 ToxicDetector,一种用于高效检测 LLM 中有害提示的轻量级灰盒方法。ToxicDetector 利用 LLM 生成有害概念提示,通过嵌入向量构建特征向量,再使用多层感知器(MLP)分类器完成提示分类。我们在 LLama 多版本模型、Gemma-2 及多个数据集上的评估显示,ToxicDetector 准确率达 96.39%,假阳性率低至 2.00%,性能优于现有最优方法。此外,ToxicDetector 单条提示处理时间为 0.0780 秒,非常适合实时应用。ToxicDetector 兼具高准确率、高效率和可扩展性,是一种实用的 LLM 有害提示检测方法。

英文摘要:

Large language models (LLMs) like ChatGPT and Gemini have significantly advanced natural language processing, enabling various applications such as chatbots and automated content generation. However, these models can be exploited by malicious individuals who craft toxic prompts to elicit harmful or unethical responses. These individuals often employ jailbreaking techniques to bypass safety mechanisms, highlighting the need for robust toxic prompt detection methods. Existing detection techniques, both blackbox and whitebox, face challenges related to the diversity of toxic prompts, scalability, and computational efficiency. In response, we propose ToxicDetector, a lightweight greybox method designed to efficiently detect toxic prompts in LLMs. ToxicDetector leverages LLMs to create toxic concept prompts, uses embedding vectors to form feature vectors, and employs a Multi-Layer Perceptron (MLP) classifier for prompt classification. Our evaluation on various versions of the LLama models, Gemma-2, and multiple datasets demonstrates that ToxicDetector achieves a high accuracy of 96.39\% and a low false positive rate of 2.00\%, outperforming state-of-the-art methods. Additionally, ToxicDetector's processing time of 0.0780 seconds per prompt makes it highly suitable for real-time applications. ToxicDetector achieves high accuracy, efficiency, and scalability, making it a practical method for toxic prompt detection in LLMs.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑