Abstract
Task Arithmetic (TA) has emerged as a powerful technique for model merging, yet its theoretical underpinnings have remained largely unexplored. This paper establishes a formal link between task vectors and the gradients of task losses. We demonstrate that task vectors generated after a single epoch of gradient descent are mathematically equivalent to the negative gradient, effectively performing a step of joint multitask learning. Our analysis explains why "premature" task vectors often outperform fully converged ones in merging scenarios, providing both theoretical bounds and empirical validation across diverse vision benchmarks.
Introduction
In the contemporary "pretrain-then-finetune" paradigm, specialized models are frequently derived from a shared base model. Managing these models individually is resource-intensive. Model merging, specifically Task Arithmetic (TA), addresses this by creating "task vectors"—the difference between fine-tuned and pretrained weights—which can be summed to produce a multitask model. Despite its empirical success, TA lacks a rigorous theoretical foundation. Notably, researchers have observed that merging models before full convergence often yields superior results. This study bridges this gap by analyzing task arithmetic through the lens of gradient descent dynamics.
Theoretical Framework
The authors analyze task arithmetic using standard full-batch Gradient Descent (GD). A task vector $\tau_t$ is defined as the parameter displacement $\theta_t - \theta_{base}$ following fine-tuning on task $t$.
The core of this work is Theorem 1, which establishes:
- Exact Equivalence: After exactly one epoch of GD, a task vector is identical to the scaled negative gradient of the loss. Summing these vectors is thus equivalent to a single step of joint multitask learning.
- Approximate Equivalence: For multiple epochs, the TA result diverges from the joint multitask path by a second-order error term $O(\eta^2)$, governed by the Hessian of the loss surface.
Further, Theorem 2 provides explicit error bounds for feed-forward networks, assuming bounded weights and activation derivatives.
Experimental Results
The theory was validated across seven vision benchmarks, including CIFAR100, SVHN, RESISC45, MNIST, EuroSAT, GTSRB, DTD, and SUN397.
Performance and Gradient Alignment
Empirical results confirm that merging models after just one epoch performs comparably to merging fully converged models. This suggests that the initial gradient determines the primary direction of the fine-tuning trajectory, with subsequent epochs offering diminishing returns for the purpose of merging.
Analysis of gradient cosine similarity shows that early gradients (first five epochs) maintain high alignment (>0.8) with the initial direction. This supports the insight that task proficiency does not necessarily equate to mergeability; lightly fine-tuned models remain within the "tangent space" of the base model, facilitating linear combination.
Trajectory Analysis
PCA visualizations reveal that iterative task arithmetic—taking multiple small steps—more effectively navigates the parameter space toward a multitask optimum compared to one-shot merging, which may overshoot the target region.
Conclusion and Future Work
This work provides a foundational theoretical explanation for task arithmetic, identifying task vectors as first-order approximations of multitask learning. While the current proofs focus on full-batch GD and feed-forward architectures, future research will aim to extend these findings to Stochastic Gradient Descent (SGD) and more complex architectures like Transformers. Understanding these dynamics is crucial for developing more efficient and predictable model merging strategies in large-scale machine learning.
Summary updated