Skip to content

katoro8989/tau-Jp_Task_Arithmetic

Repository files navigation

Task Addition

Task Negation

Abstract

Model-editing techniques using task arithmetic (Ilharco et al., 2022) have rapidly gained attention. Through task arithmetic, simply through arithmetic operations on the weights of pre-trained and fine-tuned models create desired models, such as multi-task models, models with specific tasks unsolvable, or domain-transferred models. However, task arithmetic faces challenges, such as low reproducibility and the high cost associated with adjusting coefficients in the arithmetic operations on model parameters, which have limited its practical success. In this paper, we present three key contributions in the context of task addition and task negation within task arithmetic. First, we propose a new metric called $\tau$Jp which is based on the product of the task vector ($\tau$) and the Jacobian of the pre-trained model with respect to its weights. We show that $\tau$Jp has a causal relationship with the interference that occurs from arithmetic operations. Second, we show that introducing regularization to minimize $\tau$Jp significantly mitigates interference between task inferences, which leads to eliminating coefficient tuning and better accuracy on each task. Third, in the context of continual learning, we confirmed that our $\tau$Jp regularization demonstrates more robust performance in environments where future tasks to be learned are not accessible, confirming the scalability of the approach. Finally, we demonstrate that the $\tau$Jp regularizer further reinforces the performance of task arithmetic by leveraging publicly available fine-tuned models, offering practical benefits for real-world applications.

Setup environment

Create a virtual environment

python3 -m venv tau_jp

Activate the virtual environment

source tau_jp/bin/activate

Install the required packages from requirements.txt

pip install -r requirements.txt

Download datasets

Datasets to download:

  1. Cars
  2. DTD
  3. EuroSAT
  4. MNIST
  5. GTSRB
  6. RESISC45
  7. SUN397
  8. SVHN
  9. ImageNet

We are using the same datasets as this repository.

For Cars, the original download link is broken, so please refer to this issue for a workaround. For DTD, EuroSAT, RESISC45, and SUN397, the datasets need to be manually split after downloading. Please refer to this issue for details.

Content

The contents of this repository are based on Ilharco et al., 2023 and Ortiz-Jimenez et al., 2023 and share the same structure.

Training

with our strict reguralizer

python src/finetune_reg_strict.py --finetuning-mode=linear --model=ViT-B-32 --world-size=2 # Finetune non-linearly on 2 GPUs

with our cyclycal reguralizer

python src/finetune_reg_efficient.py --finetuning-mode=linear --model=ViT-B-32 --world-size=2 # Finetune non-linearly on 2 GPUs

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages