Skip to main content
QUICK REVIEW

[论文解读] Steering Language Models With Activation Engineering

Alexander Turner, Lisa Thiergart|arXiv (Cornell University)|Aug 20, 2023
Explainable Artificial Intelligence (XAI)被引用 4
一句话总结

本文提出激活加法(ActAdd),一种在推理阶段通过计算提示对之间激活差异生成的控制向量,实现对大语言模型的无优化、无标注数据的推理时控制方法。该方法支持通过自然语言控制模型行为,如情感、主题或风格,同时保持模型性能并随模型规模高效扩展。

ABSTRACT

Prompt engineering and finetuning aim to maximize language model performance on a given metric (like toxicity reduction). However, these methods do not fully elicit a model's capabilities. To reduce this gap, we introduce activation engineering: the inference-time modification of activations in order to control (or steer) model outputs. Specifically, we introduce the Activation Addition (ActAdd) technique, which contrasts the intermediate activations on prompt pairs (such as "Love" versus "Hate") to compute a steering vector (Subramani et al. 2022). By tactically adding in e.g. the "Love" - "Hate" steering vector during the forward pass, we achieve SOTA on negative-to-positive sentiment shift and detoxification using models including LLaMA-3 and OPT. ActAdd yields inference-time control over high-level output properties (like topic and sentiment) while preserving performance on off-target tasks. ActAdd is lightweight: it does not require any machine optimization and works with a single pair of data points, which enables rapid iteration over steering. ActAdd demonstrates the power of activation engineering.

研究动机与目标

  • 解决在不使用计算成本高昂的微调或强化学习的情况下,可靠控制大语言模型的挑战。
  • 在推理阶段实现用户友好的、通过自然语言指定期望模型行为。
  • 开发一种轻量级、可扩展的模型控制方法,避免反向传播和标注数据。
  • 在实现对情感、主题和风格等高层输出属性的针对性控制的同时,保持模型整体性能。

提出的方法

  • 通过计算两个对比提示(如 'I love you' 与 'I hate you')产生的激活差异,生成控制向量。
  • 在推理过程中,通过将控制向量加到特定层的残差流激活中,对模型进行控制。
  • 通过可学习的系数对控制向量进行缩放,以控制行为转变的强度。
  • 仅需前向传播——生成控制向量无需反向传播、微调或标注数据。
  • 在冻结的大语言模型上于推理阶段应用该方法,实现实时控制而无需重新训练。
  • 通过消融实验或启发式搜索选择最优层和系数,以最大化期望的行为改变。
Figure 1: Schematic of the Activation Addition ( ActAdd ) method. $=$ natural language text; $\bullet$ = vectors of activations just before a specified layer. In this example, the output is heavily biased towards discussing weddings, regardless of the topic of the user prompt. (See Algorithm 1 for o
Figure 1: Schematic of the Activation Addition ( ActAdd ) method. $=$ natural language text; $\bullet$ = vectors of activations just before a specified layer. In this example, the output is heavily biased towards discussing weddings, regardless of the topic of the user prompt. (See Algorithm 1 for o

实验结果

研究问题

  • RQ1自然语言提示对之间的激活差异是否能可靠地生成用于推理阶段控制的有效控制向量?
  • RQ2ActAdd 是否在分布外或非目标任务上保持了模型的整体性能?
  • RQ3该方法在模型规模增大时的扩展性如何?与微调或RLHF相比,其计算开销如何?
  • RQ4ActAdd 是否能对情感或主题等特定属性实现单调或非单调控制?其行为背后的解释是什么?
  • RQ5该方法在不同模型(如 GPT-2、Llama-13B 和 GPT-J-6B)上是否具有鲁棒性?是否在多样化的提示中具有泛化能力?

主要发现

  • ActAdd 在 OpenWebText 和 ConceptNet 上成功对 GPT-2 实现了情感、主题和风格的控制,计算成本极低且无需微调。
  • 该方法在非目标任务上保持了模型性能,表现出良好的鲁棒性和泛化能力。
  • 在 GPT-2 上,ActAdd 仅通过前向传播和无标注数据,即实现了对输出属性的显著控制——例如,将生成内容从 'hate' 转变为 'love'。
  • 当修改残差流维度的分数时,观察到非单调行为,表明激活空间中存在复杂的特征表示,可能具有轴对齐特性。
  • 该方法自然地随模型规模扩展,且相比其他需要基于梯度优化的激活工程方法,实现更为简便。
  • 在 Llama-13B 上的复现结果类似,但部分提示(如埃菲尔铁塔事实)出现复现失败,表明方法对上下文和特征对齐存在敏感性。
Figure 2: Performance of ActAdd on a target topic as the topic becomes more relevant. The perplexity ratio (lower better) compares the relative predictive performance of ActAdd and an unmodified model; we see that adding a wedding - ‘ ’ steering vector improves performance on wedding-related text wh
Figure 2: Performance of ActAdd on a target topic as the topic becomes more relevant. The perplexity ratio (lower better) compares the relative predictive performance of ActAdd and an unmodified model; we see that adding a wedding - ‘ ’ steering vector improves performance on wedding-related text wh

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。