跳转至

安全性的不稳定性:随机种子与温度如何暴露出大模型不一致的拒绝行为

文章背景与核心概要

当前对大型语言模型(LLM)的安全性评估通常依赖于单次测试(single-shot testing),这种方法默认模型的响应是确定的,并且能够全面代表其安全对齐水平。《安全性的不稳定性》一文挑战了这一核心假设,深入探讨了随机种子和温度设置如何影响模型安全拒绝决策的稳定性。

该研究测试了多个模型系列中的四个指令微调模型,涵盖 876 个有害提示词。结果表明,有 18% 到 28% 的提示词会出现“决策反转”(decision flips)——即模型在某些配置下会拒绝请求,但在其他配置下却会予以满足。这些发现证明,单次安全性评估根本无法满足需求,并呼吁建立能够随温度扩展的、更加稳健的多样本评估协议。


摘要

Current safety evaluations of large language models (LLMs) typically rely on single-shot testing, assuming that a model's responses are deterministic and universally representative of its safety alignment. "The Instability of Safety" challenges this core assumption by investigating how random seeds and temperature settings affect the stability of safety refusal decisions.

当前对大型语言模型(LLM)的安全性评估通常依赖于单次测试,默认模型的响应是确定性的,并且能够普遍代表其安全对齐状态。《安全性的不稳定性》一文调查了随机种子和温度设置如何影响安全拒绝决策的稳定性,从而对这一核心假设提出了挑战。

Evaluating four instruction-tuned models across multiple families on 876 harmful prompts, the study reveals that 18% to 28% of prompts exhibit decision flips—meaning the model refuses a request in some configurations but complies in others. The findings demonstrate that single-shot safety evaluations are fundamentally insufficient and call for robust multi-sample evaluation protocols that scale with temperature.

该研究在来自多个系列的四个指令微调模型上评估了 876 个有害提示词,结果表明:18% 至 28% 的提示词表现出决策反转——这意味着模型在某些配置下会拒绝请求,而在其他配置下则会顺从。这些发现表明,单次安全性评估从根本上是不够的,并呼吁采用随温度缩放的、稳健的多样本评估协议。


关键发现与方法论

  • Scope of Study: Tested four instruction-tuned models from three major families (Llama 3.1 8B, Qwen 2.5 7B, Qwen 3 8B, and Gemma 3 12B) across 876 harmful prompts from combined datasets (AdvBench + HarmBench) over 20 sampling configurations (4 temperatures \(\times\) 5 seeds).
  • 研究范围: 测试了来自三个主流系列的四个指令微调模型(Llama 3.1 8B、Qwen 2.5 7B、Qwen 3 8B 和 Gemma 3 12B),数据集涵盖了组合数据集(AdvBench + HarmBench)中的 876 个有害提示词,并在 20 种采样配置(4 种温度 \(\times\) 5 个种子)下进行了测试。
  • The Safety Stability Index (SSI): Higher temperatures significantly degrade decision stability (\(\chi^2 = 396.81, p < 0.001\)). The mean within-temperature SSI drops from 0.977 at temperature 0.0 to 0.942 at temperature 1.0.
  • 安全性稳定指数(SSI): 更高的温度会显着降低决策稳定性(\(\chi^2 = 396.81, p < 0.001\))。在相同温度下的平均 SSI 从 \(T=0.0\) 时的 0.977 下降到 \(T=1.0\) 时的 0.942
  • Borderline Instability: Prompts with higher baseline compliance rates exhibit lower stability (\(\rho = -0.47 \text{ to } -0.70, p < 0.001\)), indicating that models actively "waver" on requests sitting close to safety boundaries.
  • 边界不稳定性: 具有较高基线顺从率的提示词表现出更低的稳定性(\(\rho = -0.47 \text{ 至 } -0.70, p < 0.001\)),这表明模型在处于安全边界附近的请求上会表现出剧烈的“动摇”。
  • Evaluation Accuracy: For Llama 3.1 8B, traditional single-shot evaluation matches multi-sample ground truth only 92.5% of the time when pooling across temperatures (ranging from 98.7% at greedy decoding down to 90.3% at temperature 1.0).
  • 评估准确率: 对于 Llama 3.1 8B 而言,当跨温度汇总时,传统的单次评估仅在 92.5% 的情况下与多样本真实基准相符(在贪婪解码时为 98.7%,在温度 1.0 时降至 90.3%)。

未来评估建议

To address stochastic variation in model safety behavior, the author recommends moving away from flat, single-shot thresholds. Instead, evaluation protocols should scale sample counts based on temperature:

为了应对模型安全行为中的随机变化,作者建议摒弃单一、静态的单次测试阈值。相反,评估协议应该根据温度来调整样本数量

  • 1 sample at greedy decoding (\(T = 0.0\))
  • 贪婪解码时(\(T = 0.0\)):1 个样本
  • 3 samples at low temperatures
  • 低温时:3 个样本
  • More samples at higher temperatures (where 3 samples only achieve ~95% coverage)
  • 高温时:更多样本(此时 3 个样本只能达到约 95% 的覆盖率)
  • 10 samples when pooling across mixed temperature settings
  • 跨混合温度设置进行汇总时:10 个样本