arXiv:2504.18827cs.SEcs.AI2025-04被引 4

用软件测试思路发现大模型提示词中的隐藏错误

Test It Before You Trust It: Applying Software Testing for Trustworthy In-context Learning

  • 借鉴软件测试,用变异扰动检测提示词漏洞
  • 实测发现主流大模型在情感分析中存在多种语言缺陷
  • 适合关注大模型可靠性的研究人员与工程师

上下文学习(ICL)是大型语言模型(LLMs)的一项重要能力,使其能在不进行显式微调的情况下,基于少量示例完成新任务。尽管具备出色适应性,这些模型仍易受细微对抗扰动影响,在面对语言变化时表现出不可预测行为。受软件测试启发,我们提出一种名为MMT4NL的测试框架,通过对抗扰动和软件测试技术评估ICL的可信度。该框架围绕从测试集生成变异对抗样本展开,以量化并定位ICL提示设计中的缺陷。我们的核心理念是将任何大模型视为软件,像验证软件功能一样验证其性能。实验表明,MMT4NL在情感分析和问答任务中能揭示当前领先模型中的多种语言层面缺陷。

原文摘要 · Abstract (English)

In-context learning (ICL) has emerged as a powerful capability of large language models (LLMs), enabling them to perform new tasks based on a few provided examples without explicit fine-tuning. Despite their impressive adaptability, these models remain vulnerable to subtle adversarial perturbations and exhibit unpredictable behavior when faced with linguistic variations. Inspired by software testing principles, we introduce a software testing-inspired framework, called MMT4NL, for evaluating the trustworthiness of in-context learning by utilizing adversarial perturbations and software testing techniques. It includes diverse evaluation aspects of linguistic capabilities for testing the ICL capabilities of LLMs. MMT4NL is built around the idea of crafting metamorphic adversarial examples from a test set in order to quantify and pinpoint bugs in the designed prompts of ICL. Our philosophy is to treat any LLM as software and validate its functionalities just like testing the software. Finally, we demonstrate applications of MMT4NL on the sentiment analysis and question-answering tasks. Our experiments could reveal various linguistic bugs in state-of-the-art LLMs.

大模型测试上下文学习对抗攻击

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。