arXiv:2409.06927cs.LGcs.CL2024-09被引 2

通过微调让大模型更诚实,无需运行时干预。

Representation Tuning

  • 用向量直接微调模型,让输出更诚实或不诚实。
  • 结合余弦相似度与词元损失,效果优于在线控制。
  • 适合关注模型安全、可控性研究的开发者。

激活工程正成为控制大语言模型(LLM)推理行为的重要手段。本文将推理时方向向量的调控扩展为直接将行为向量融入模型权重中,避免了在线调节的依赖。首先,在开源模型 Llama-2-13b-chat 中识别出与诚实性相关的激活向量;随后验证,通过在生成过程中向残差流添加正负倍数的该向量,可使输出更诚实或不诚实;接着提出一种双损失微调方法('representation tuning'),结合余弦相似度损失与标准词元损失,将向量直接嵌入模型;最后对比发现,该方法生成结果在诚实性上比仅使用词元损失微调的模型更强,且优于在线向量调控,表明其在安全性方面的潜力。代码与数据已公开于 GitHub,微调模型可在 Hugging Face 获取。

原文摘要 · Abstract (English)

Activation engineering is becoming increasingly popular as a means of online control of large language models (LLMs). In this work, we extend the idea of inference-time steering with vectors that represent a behavioral direction of interest to tuning those vectors directly into the model, obviating the need for online control. First, we identify activation vectors related to honesty in an open-source LLM (Llama-2-13b-chat). Next, we demonstrate that model output can be made more or less honest by adding positive or negative multiples of these vectors to residual stream activations during generation. Then, we show that a similar effect can be achieved by fine-tuning the vectors directly into the model, by use of a dual loss function based on the cosine similarity of residual stream activations to the vectors combined with a standard token-based loss ("representation tuning"). Finally, we compare the generations in response to honesty-probing prompts from the resulting models to those from models fine-tuned with a token-based loss alone, and to those from the untuned model subjected to online steering. Overall, fine-tuning the vectors into the models using the cosine similarity plus token loss showed a stronger effect than online steering, and generalized better than using the standard loss, suggesting the potential utility of this approach as a safety measure. Code and data are available at https://github.com/cma1114/representation_tuning. Tuned models are available at https://huggingface.co/collections/cackerman/representation-tuning-66da1e5ab41cd1b824687d9f.

大模型安全向量微调推理控制

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