Editing Models with Task Arithmetic
TL;DR. Fine-tune a model on a task and subtract the pre-trained weights: the difference is a task vector. Adding scaled task vectors gives multi-task models, negating one removes a behaviour, and analogies between tasks can produce a model for a task with no training data.
Key idea
Section titled “Key idea”Task vectors are applied element-wise to any model with the same architecture: (§2). Negation uses ; addition uses ; analogies use . The scale is chosen on held-out validation data.
Results. Negating a task vector from GPT-2 Large fine-tuned on toxic data reduces toxic generations by 6× with comparable WikiText-103 perplexity (§3.2, Table 2). Adding task vectors from eight CLIP image tasks reaches 91.2% average normalised accuracy, where 100% is the accuracy of using a separate fine-tuned model per task (§4.1).
Connections
Section titled “Connections”- Activation addition does the same arithmetic on activations instead of weights.
- ROME edits weights with a targeted rank-one update rather than a whole fine-tuning delta.
- Weight-space programming has an LLM read and write weight edits directly.
- LoRA produces low-rank task updates that are natural task vectors.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
With τ_A = θ_A − θ_pre and τ_B = θ_B − θ_pre, write the merged model for adding both tasks with scale λ, the model that forgets task A, and the analogy model for "A is to B as C is to D". What does each assume about how the task updates interact?
What a strong answer covers
- Addition: θ_new = θ_pre + λ(τ_A + τ_B).
- Negation: θ_new = θ_pre − λτ_A, which extrapolates past the pre-trained model away from the fine-tuned one.
- Analogy: τ_D ≈ τ_C + (τ_B − τ_A), so θ_new = θ_pre + λ(τ_C + τ_B − τ_A), using no data from task D.
- All assume updates combine approximately linearly near θ_pre, i.e. that task vectors interfere little; λ is tuned on held-out data to control this.
- Mechanism
Negating a toxicity task vector on GPT-2 Large cut toxic generations about 6× with similar WikiText-103 perplexity. Explain why moving away from a fine-tuned model can remove a behaviour without destroying general ability.
What a strong answer covers
- Fine-tuning on toxic text moves weights mainly along directions that increase toxic continuations; the rest of the change is small.
- Subtracting that delta from the pre-trained model pushes those same directions the other way, reducing the behaviour.
- Because the delta is concentrated on the task, control-task performance (perplexity on WikiText-103) changes little at a tuned λ.
- If the task vector also encoded general language skills, negation would hurt perplexity; the control task is the check for this.
- Design
You have one embedding model fine-tuned for biomedical retrieval and one for legal retrieval, both from the same base. Plan how to use task arithmetic to build a single model, and what to measure.
What a strong answer covers
- Compute τ_bio and τ_legal against the shared base, then add with λ tuned on a held-out mix of both domains.
- Measure nDCG@10 on each domain relative to the specialist models (normalised accuracy as in the paper) and on a general benchmark as a control.
- Check interference: if adding hurts one domain, try per-layer λ or merging only part of the network.
- Also test negation to remove an unwanted bias (for example a length preference) learned by one fine-tune.