[Paper Review] Editing Models with Task Arithmetic
This paper introduces task vectors, a weight-space arithmetic method to edit pre-trained models. By computing differences between fine-tuned and pre-trained weights, it enables negation, addition, and analogies of tasks to steer model behavior without extra training.
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 extit{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.
Motivation & Objective
- Provide a lightweight, post-training mechanism to steer model behavior along task directions in weight space.
- Show that task vectors can be negated to forget or reduce undesired behaviors with minimal collateral impact.
- Demonstrate that adding task vectors yields multi-task models and can improve single-task performance.
- Explore task analogies to transfer knowledge across domains or subpopulations with scarce data.
Proposed method
- Define a task vector as the element-wise difference between a model's weights after fine-tuning on a task and the same model's pre-trained weights (τ_t = θ_ft^t − θ_pre).
- Apply task vectors to model weights via θ_new = θ + λτ_new with a tunable scalar λ chosen by held-out validation.
- Study three arithmetic operations on task vectors: negation (−τ), addition (Στ_i), and analogy-based combination (τ_C + (τ_B − τ_A)).
- Evaluate on open-ended architectures (image and language models) across multiple tasks and datasets to assess editing efficacy and robustness.
Experimental results
Research questions
- RQ1Can negating a task vector reduce target-task performance while preserving control-task performance?
- RQ2Does adding multiple task vectors yield a competitive multi-task model relative to using separate fine-tuned models?
- RQ3Can task analogies transfer improvements to target tasks with little or no labeled data for that task?
- RQ4What are the effects of learning rate and task similarity on the usefulness of task vectors?
Key findings
- Negating a task vector can substantially reduce target-task performance (e.g., average target accuracy drops by 45.8 percentage points on ViT-L/14 for forgetting) with little change to control tasks.
- Negating a task vector for toxic-generation prompts in GPT-2 reduces toxic generations from 4.8% to 0.8% while keeping WikiText-103 perplexity close to the pre-trained model (within 0.5 points).
- Adding task vectors from multiple tasks yields a single model that is competitive with or better than using multiple specialized models (normalized accuracy approach near or above 98.9% when combining two tasks; overall multi-task accuracy improves as more vectors are added).
- Task analogies (A is to B as C is to D) can improve performance on D even with little or no data for D, demonstrated in sentiment analysis domain generalization and subpopulation settings.
- For NLP, adding external task vectors to fine-tuned T5 models can improve target-task accuracy on GLUE tasks (e.g., MRPC, RTE, CoLA, SST-2) compared with zero-shot or base fine-tuned models.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.