Skip to main content
QUICK REVIEW

[论文解读] On Prompt-Driven Safeguarding for Large Language Models

Chujie Zheng, Fan Yin|arXiv (Cornell University)|Jan 31, 2024
VLSI and Analog Circuit TestingComputer Science被引用 5
一句话总结

本文分析安全提示如何通过表示影响大模型的安全防护,并引入DRO,一种通过将查询表示向拒绝方向移动来自动优化安全提示的方法。

ABSTRACT

Prepending model inputs with safety prompts is a common practice for safeguarding large language models (LLMs) against queries with harmful intents. However, the underlying working mechanisms of safety prompts have not been unraveled yet, restricting the possibility of automatically optimizing them to improve LLM safety. In this work, we investigate how LLMs' behavior (i.e., complying with or refusing user queries) is affected by safety prompts from the perspective of model representation. We find that in the representation space, the input queries are typically moved by safety prompts in a "higher-refusal" direction, in which models become more prone to refusing to provide assistance, even when the queries are harmless. On the other hand, LLMs are naturally capable of distinguishing harmful and harmless queries without safety prompts. Inspired by these findings, we propose a method for safety prompt optimization, namely DRO (Directed Representation Optimization). Treating a safety prompt as continuous, trainable embeddings, DRO learns to move the queries' representations along or opposite the refusal direction, depending on their harmfulness. Experiments with eight LLMs on out-of-domain and jailbreak benchmarks demonstrate that DRO remarkably improves the safeguarding performance of human-crafted safety prompts, without compromising the models' general performance.

研究动机与目标

  • 从表示角度调查安全提示如何影响LLM的安全防护。
  • 验证关于有害与无害查询可分性及拒绝动态的假设。
  • 开发基于表示空间的自动化安全提示优化方法(DRO)。

提出的方法

  • 收集并综合受控的有害/无害查询,以研究表示效应。
  • 在不同安全提示下,使用PCA对八个开源7B级LLM的模型表示进行可视化。
  • 提出DRO,以学习连续的安全提示嵌入,使查询表示沿着/拒绝方向移动;包括一个正则化项以保持通用能力。
  • 在安全锚数据上使用PCA锚定一个低维表示空间,并拟合逻辑回归以估计拒绝方向。
  • 用对比目标优化连续安全提示,使对有害查询的拒绝增加,对无害查询的拒绝减少;并加入正则化项以防止退化。

实验结果

研究问题

  • RQ1安全提示是提高对有害性的识别,还是总体上增加拒绝概率?
  • RQ2安全提示如何改变潜在空间中有害与无害查询的表示?
  • RQ3是否可以优化连续的安全提示,以在提升安全防护的同时保持通用模型能力?
  • RQ4表示空间中是否存在可衡量的拒绝方向,可以指导提示优化?

主要发现

  • 安全提示使查询表示朝相似方向移动,即使无害查询也会提高总体拒绝概率。
  • 在没有安全提示的情况下,有害/无害查询在表示空间中仍然可辨;这对“提示主要提升对有害性识别”的观点提出挑战。
  • DRO在领域外基准测试上显著提升安全防护(例如,在AdvBench上对LLaMA-2安全提示将有害查询的合规性从10.3%降至1.4%)。
  • DRO在性能上优于普通的Prompt-Tuning,并在AlpacaEval上保持通用模型能力。
  • 正则化对于在优化安全提示的同时维持生成质量至关重要。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。