arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2511.21752cs.CLcs.AI
收藏

语义作为盾牌:对抗大语言模型情感分类中提示注入的标签伪装防御(LDD)

Semantics as a Shield: Label Disguise Defense (LDD) against Prompt Injection in LLM Sentiment Classification

Department of Computer Science, George Washington University(计算机科学系,乔治华盛顿大学)

Yanxi Li, Ruocheng Shan

AI总结:

本文提出LDD,一种通过语义伪装标签来防御大语言模型情感分类中提示注入攻击的方法,展示了其在不同模型上的有效性。

摘要:

大型语言模型越来越多地用于文本分类任务,如情感分析,但它们对自然语言提示的依赖使它们容易受到提示注入攻击。特别是,类别指令注入利用对模型标签集(例如积极与消极)的了解,通过对抗性指令覆盖其预期行为。现有的防御措施,如基于检测的过滤器、指令层级和签名提示,要么需要模型重新训练,要么仍然容易受到混淆攻击。本文介绍了标签伪装防御(LDD),一种轻量且模型无关的策略,通过将真实标签替换为语义转换或无关的别名标签(例如蓝色与黄色)来隐藏真实标签。模型通过少量示例学习这些新标签映射,防止注入指令与决策输出之间的直接对应关系。我们评估了LDD在九种最先进的模型上的表现,包括GPT-5、GPT-4o、LLaMA3.2、Gemma3和Mistral变体,在不同少量示例和对抗性设置下。我们的结果表明,LDD在对抗性攻击中恢复性能的能力因模型和别名选择而异。对于每个评估的模型,LDD都能恢复一部分因攻击造成的准确性损失。此外,对于大多数模型,我们能够识别出多个别名对,其准确性高于仅依赖少量示例学习而无任何防御机制的基线。进一步的语义分析还揭示,语义一致的别名标签(例如好与坏)比不一致的符号(例如蓝色与黄色)更具鲁棒性。总体而言,本研究证明了标签语义可以作为一种有效的防御层,将意义本身转化为对抗提示注入的盾牌。

英文摘要:

Prompt injection can cause large language models (LLMs) to deviate from their intended tasks by following instructions embedded in untrusted input. We investigate whether changing a classifier's output labels improves accuracy under such attacks, using sentiment classification as a case study. Label Disguise Defense (LDD) replaces positive/negative with alternatives such as good/bad or cat/dog, introduced through demonstrations, and maps predictions back to sentiment classes. We analyze retained aggregate results for 200 IMDb reviews, nine recorded model configurations, and eight alternative label pairs under a fixed attack that always requests the incorrect class using the original labels. Averaged over four pairs per group, sentiment-associated labels outperform the other tested labels in all nine configurations, but exceed a baseline using the original labels and the same demonstration and attack conditions in only three. At least one alternative pair improves on this baseline in seven configurations, with the best pairs identified retrospectively. These results show that a consistent advantage between label groups does not imply consistent improvement over standard labels. Missing matched evaluations on unattacked reviews prevent separating changes in ordinary classification performance from changes in the effect of the attack.

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

↑