Changing how pre-trained models behave -- e.g., improving their performance on a downstream task or mitigating biases learned during pre-training -- is a common practice when developing machine learning systems. In this work, we propose a new paradigm for steering the behavior of neural networks, centered around \textit{task vectors}. A task vector specifies a direction in the weight space of a pre-trained model, such that movement in that direction improves performance on the task. We build task vectors by subtracting the weights of a pre-trained model from the weights of the same model after fine-tuning on a task. We show that these task vectors can be modified and combined together through arithmetic operations such as negation and addition, and the behavior of the resulting model is steered accordingly. Negating a task vector decreases performance on the target task, with little change in model behavior on control tasks. Moreover, adding task vectors together can improve performance on multiple tasks at once. Finally, when tasks are linked by an analogy relationship of the form ``A is to B as C is to D", combining task vectors from three of the tasks can improve performance on the fourth, even when no data from the fourth task is used for training. Overall, our experiments with several models, modalities and tasks show that task arithmetic is a simple, efficient and effective way of editing models.
翻译:改变预训练模型的行为是开发机器学习系统中的常见做法,例如提升其在特定下游任务上的性能,或减轻预训练过程中习得的偏见。本文提出了一种以任务向量为核心的神经网络行为调控新范式。任务向量定义了预训练模型权重空间中的一个方向,沿该方向调整权重可提升目标任务性能。我们通过将微调后模型的权重减去原始预训练模型的权重来构建任务向量。研究表明,这些任务向量可通过求反与求和等算术运算进行修改与组合,从而按需调控模型行为:对任务向量求反会降低目标任务性能,但对控制任务上的模型行为影响甚微;而将多个任务向量相加可同时提升多个子任务的表现。此外,当任务间存在"A对B相当于C对D"的类比关系时,即使未使用第四个任务的训练数据,组合其中三个任务的任务向量仍能提升第四个任务的性能。我们在多种模型、模态及任务上的实验表明,任务算术是一种简单、高效且有效的模型编辑方法。