arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.17132cs.SEcs.CL
收藏

ASTRAL:大型语言模型的自动化安全测试

ASTRAL: Automated Safety Testing of Large Language Models

Mondragon University(蒙德拉贡大学);University of Seville(塞维利亚大学)

Miriam Ugarte, Pablo Valle, José Antonio Parejo, Sergio Segura, Aitor Arrieta

AI总结:

本文提出ASTRAL,一种自动化生成和执行测试用例以测试LLM安全性的工具,通过引入新颖的黑盒覆盖准则和基于RAG、少样本提示及网络浏览的方法,显著提升了不安全行为的发现率。

摘要:

大型语言模型(LLMs)近期因其理解和生成复杂且类人内容的能力而备受关注。然而,确保其安全性至关重要,因为它们可能会提供有害和不安全的响应。现有的LLM测试框架解决了各种与安全相关的问题(例如毒品、恐怖主义、虐待动物),但通常由于数据集不平衡和过时而面临挑战。在本文中,我们提出了ASTRAL,这是一种自动化生成和执行测试用例(即提示词)以测试LLM安全性的工具。首先,我们引入了一种新颖的黑盒覆盖准则,以在各种安全类别以及语言学写作特征(即不同的风格和说服性写作技巧)中生成平衡且多样的不安全测试输入。其次,我们提出了一种基于LLM的方法,该方法利用检索增强生成(RAG)、少样本提示策略和网络浏览来生成最新的测试输入。最后,与当前的LLM测试自动化技术类似,我们利用LLM作为测试预言机来区分安全和不安全的测试输出,从而实现完全自动化的测试方法。我们在知名的LLM上进行了广泛的评估,揭示了以下关键发现:i)GPT3.5在作为测试预言机时优于其他LLM,能够准确检测不安全的响应,甚至超越了较新的LLM(例如GPT-4),以及专门为检测不安全LLM输出而量身定制的LLM(例如LlamaGuard);ii)结果证实,与当前使用的静态数据集相比,在相同数量的测试输入下,我们的方法能够发现近两倍的不安全LLM行为;iii)我们的黑盒覆盖准则结合网络浏览,能够有效引导LLM生成最新的不安全测试输入,显著增加了不安全LLM行为的数量。

英文摘要:

Large Language Models (LLMs) have recently gained attention due to their ability to understand and generate sophisticated human-like content. However, ensuring their safety is paramount as they might provide harmful and unsafe responses. Existing LLM testing frameworks address various safety-related concerns (e.g., drugs, terrorism, animal abuse) but often face challenges due to unbalanced and obsolete datasets. In this paper, we present ASTRAL, a tool that automates the generation and execution of test cases (i.e., prompts) for testing the safety of LLMs. First, we introduce a novel black-box coverage criterion to generate balanced and diverse unsafe test inputs across a diverse set of safety categories as well as linguistic writing characteristics (i.e., different style and persuasive writing techniques). Second, we propose an LLM-based approach that leverages Retrieval Augmented Generation (RAG), few-shot prompting strategies and web browsing to generate up-to-date test inputs. Lastly, similar to current LLM test automation techniques, we leverage LLMs as test oracles to distinguish between safe and unsafe test outputs, allowing a fully automated testing approach. We conduct an extensive evaluation on well-known LLMs, revealing the following key findings: i) GPT3.5 outperforms other LLMs when acting as the test oracle, accurately detecting unsafe responses, and even surpassing more recent LLMs (e.g., GPT-4), as well as LLMs that are specifically tailored to detect unsafe LLM outputs (e.g., LlamaGuard); ii) the results confirm that our approach can uncover nearly twice as many unsafe LLM behaviors with the same number of test inputs compared to currently used static datasets; and iii) our black-box coverage criterion combined with web browsing can effectively guide the LLM on generating up-to-date unsafe test inputs, significantly increasing the number of unsafe LLM behaviors.

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

↑