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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- clip
|
| 5 |
+
- task-arithmetic
|
| 6 |
+
- model-merging
|
| 7 |
+
- lora
|
| 8 |
+
- fine-tuning
|
| 9 |
+
- orthogonal-regularization
|
| 10 |
+
- image-classification
|
| 11 |
+
base_model:
|
| 12 |
+
- openai/clip-vit-base-patch32
|
| 13 |
+
- openai/clip-vit-base-patch16
|
| 14 |
+
- openai/clip-vit-large-patch14
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# Understanding and Enforcing Weight Disentanglement in Task Arithmetic β LoRA-ATT Checkpoints
|
| 18 |
+
|
| 19 |
+
[CVPR 2026] Official LoRA-ATT checkpoints for the paper **"Understanding and Enforcing Weight Disentanglement in Task Arithmetic"**.
|
| 20 |
+
|
| 21 |
+
[[Paper](https://arxiv.org/abs/2604.17078)] [[Code](https://github.com/lshangge/OrthoReg_lora)] [[OrthoReg repo](https://github.com/RL-MIND/OrthoReg)]
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
## π― Abstract
|
| 26 |
+
|
| 27 |
+
Task arithmetic provides an efficient, training-free way to edit pre-trained models, yet lacks a fundamental theoretical explanation for its success. The existing concept of "weight disentanglement" describes the ideal outcome of non-interfering task composition but does not reveal its underlying cause. Crucially, what intrinsic properties of the pre-trained model ($\theta_0$) or the task vectors ($\tau_t$) enable this disentanglement remains underexplored. In this paper, we introduce Task-Feature Specialization (TFS), a model's ability to allocate distinct internal features to different tasks, as the fundamental principle. We first prove that TFS is a sufficient condition for weight disentanglement. More importantly, we find that TFS also gives rise to an observable geometric consequence: weight vector orthogonality. This positions TFS as the common cause for both the desired functional outcome (disentanglement) and a measurable geometric property (orthogonality). This relationship provides the key insight for our method: since the abstract TFS property is intractable to enforce directly, we can instead promote weight disentanglement by shaping its concrete geometric consequence, orthogonality. Therefore, we propose OrthoReg, a simple and effective regularization method that actively enforces an internal orthogonal structure on weight updates ($\Delta W$) that constitute $\tau_t$ during fine-tuning. And we theoretically prove that OrthoReg promotes disentanglement. Extensive experiments demonstrate that OrthoReg consistently and significantly enhances the performance of various task arithmetic methods.
|
| 28 |
+
|
| 29 |
+
### β¨ Key Contributions
|
| 30 |
+
|
| 31 |
+
- π **Theory**: We identify TFS as a sufficient condition for weight disentanglement, and WVO as its geometric consequence, providing the first principled explanation for task arithmetic.
|
| 32 |
+
- π§ **Method (OrthoReg)**: A simple regularization term added to the fine-tuning loss that enforces column-wise orthogonality on ΞW, for which we prove theoretical efficacy.
|
| 33 |
+
- π **Connection to TTA**: We show that OrthoReg and Tangent Task Arithmetic (TTA) share the same underlying mechanism (i.e. inter-task vector orthogonality), but OrthoReg achieves this more efficiently.
|
| 34 |
+
- π **Experiments**: Consistent and significant improvements over Non-linear FT, TTA, ATT-FT, LoRA-ATT across ViT-B-32, ViT-B-16, and ViT-L-14.
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
### The OrthoReg Loss on LoRA-ATT
|
| 39 |
+
|
| 40 |
+
The OrthoReg loss is applied to the equivalent dense weight update implied by each LoRA module:
|
| 41 |
+
|
| 42 |
+
$$\Delta W = \frac{\alpha}{r} \cdot B A$$
|
| 43 |
+
|
| 44 |
+
$$\mathcal{L}_{\text{ortho}} = \sum_l \left\| (\Delta W^{(l)})^\top \Delta W^{(l)} - I \right\|_F^2$$
|
| 45 |
+
|
| 46 |
+
The total training loss is:
|
| 47 |
+
|
| 48 |
+
$$\mathcal{L} = \mathcal{L}_{\text{task}} + \lambda \cdot \mathcal{L}_{\text{ortho}}$$
|
| 49 |
+
|
| 50 |
+
---
|
| 51 |
+
|
| 52 |
+
## π Checkpoint Structure
|
| 53 |
+
|
| 54 |
+
This repository contains fine-tuned LoRA-ATT checkpoints for **ViT-B-32, ViT-B-16, and ViT-L-14** on all 8 tasks, covering the following finetuning modes:
|
| 55 |
+
|
| 56 |
+
| Directory | Mode | Description |
|
| 57 |
+
|---|---|---|
|
| 58 |
+
| `loraatt_1e-03_{model}/` | `loraatt` | LoRA-ATT baseline (attention-only LoRA fine-tuning) |
|
| 59 |
+
| `loraatt_ortho_1e-03_lambda{Ξ»}_{model}/` | `loraatt_ortho` | LoRA-ATT + OrthoReg |
|
| 60 |
+
|
| 61 |
+
Lambda values used per model:
|
| 62 |
+
|
| 63 |
+
| Model | `--ortho-lambda` |
|
| 64 |
+
|---|:---:|
|
| 65 |
+
| ViT-B-32 | 10.0 |
|
| 66 |
+
| ViT-B-16 | 10.0 |
|
| 67 |
+
| ViT-L-14 | 1.0 |
|
| 68 |
+
|
| 69 |
+
Each mode directory is organized by dataset:
|
| 70 |
+
|
| 71 |
+
```
|
| 72 |
+
{mode}_{lr}_{model}/
|
| 73 |
+
βββ head_CarsVal.pt # linear classification head
|
| 74 |
+
βββ head_DTDVal.pt
|
| 75 |
+
βββ head_EuroSATVal.pt
|
| 76 |
+
βββ head_GTSRBVal.pt
|
| 77 |
+
βββ head_MNISTVal.pt
|
| 78 |
+
βββ head_RESISC45Val.pt
|
| 79 |
+
βββ head_SUN397Val.pt
|
| 80 |
+
βββ head_SVHNVal.pt
|
| 81 |
+
βββ {mode}_ft_accuracies.json # single-task accuracy results
|
| 82 |
+
βββ {mode}_additions.json # task addition results
|
| 83 |
+
βββ CarsVal/
|
| 84 |
+
β βββ {mode}_finetuned.pt # fine-tuned model weights (merged task vector + ΞΈβ)
|
| 85 |
+
β βββ {mode}_zeroshot.pt # zero-shot reference weights
|
| 86 |
+
βββ DTDVal/
|
| 87 |
+
...
|
| 88 |
+
βββ SVHNVal/
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
All checkpoints use **seed=1993**, **lr=1e-3**, **lora-rank=8**, and **lora-alpha=8.0** to match the paper's reported results.
|
| 92 |
+
|
| 93 |
+
---
|
| 94 |
+
|
| 95 |
+
## π Usage
|
| 96 |
+
|
| 97 |
+
### Step 1 β Clone this repository
|
| 98 |
+
|
| 99 |
+
```bash
|
| 100 |
+
git lfs install
|
| 101 |
+
git clone https://huggingface.co/RL-MIND/OrthoReg_lora_checkpoints
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
Place the cloned folder as `checkpoints_1993/` inside your code directory:
|
| 105 |
+
|
| 106 |
+
```bash
|
| 107 |
+
mv OrthoReg_lora_checkpoints/* orthoreg_lora/checkpoints_1993/
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
### Step 2 β Install the codebase
|
| 111 |
+
|
| 112 |
+
```bash
|
| 113 |
+
git clone https://github.com/lshangge/OrthoReg_lora
|
| 114 |
+
cd orthoreg_lora
|
| 115 |
+
conda env create -f environment.yml
|
| 116 |
+
conda activate tta_peft
|
| 117 |
+
export PYTHONPATH="$PYTHONPATH:$PWD"
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
### Step 3 β Run evaluation
|
| 121 |
+
|
| 122 |
+
Generate zero-shot accuracies (required once before task addition/negation):
|
| 123 |
+
|
| 124 |
+
```bash
|
| 125 |
+
python src/eval_single_task.py \
|
| 126 |
+
--model ViT-B-32 \
|
| 127 |
+
--finetuning-mode none \
|
| 128 |
+
--data-location /path/to/datasets/
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
Evaluate single-task accuracy:
|
| 132 |
+
|
| 133 |
+
```bash
|
| 134 |
+
python src/eval_single_task.py \
|
| 135 |
+
--model ViT-B-32 \
|
| 136 |
+
--finetuning-mode loraatt \
|
| 137 |
+
--lora-rank 8 \
|
| 138 |
+
--lora-alpha 8.0 \
|
| 139 |
+
--lr 1e-3 \
|
| 140 |
+
--seed 1993 \
|
| 141 |
+
--data-location /path/to/datasets/
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
Evaluate task addition:
|
| 145 |
+
|
| 146 |
+
```bash
|
| 147 |
+
python src/eval_task_addition.py \
|
| 148 |
+
--model ViT-B-32 \
|
| 149 |
+
--finetuning-mode loraatt \
|
| 150 |
+
--lora-rank 8 \
|
| 151 |
+
--lora-alpha 8.0 \
|
| 152 |
+
--lr 1e-3 \
|
| 153 |
+
--seed 1993 \
|
| 154 |
+
--data-location /path/to/datasets/
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
Evaluate task negation:
|
| 158 |
+
|
| 159 |
+
```bash
|
| 160 |
+
python src/eval_task_negation.py \
|
| 161 |
+
--model ViT-B-32 \
|
| 162 |
+
--finetuning-mode loraatt \
|
| 163 |
+
--lora-rank 8 \
|
| 164 |
+
--lora-alpha 8.0 \
|
| 165 |
+
--lr 1e-3 \
|
| 166 |
+
--seed 1993 \
|
| 167 |
+
--data-location /path/to/datasets/
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
+
To evaluate the OrthoReg variant, replace `--finetuning-mode loraatt` with `--finetuning-mode loraatt_ortho` and add `--ortho-lambda 10.0` (or `1.0` for ViT-L-14).
|
| 171 |
+
|
| 172 |
+
### Argument reference
|
| 173 |
+
|
| 174 |
+
| Argument | Value for these checkpoints |
|
| 175 |
+
|---|---|
|
| 176 |
+
| `--seed` | `1993` |
|
| 177 |
+
| `--lr` | `1e-3` |
|
| 178 |
+
| `--lora-rank` | `8` |
|
| 179 |
+
| `--lora-alpha` | `8.0` |
|
| 180 |
+
| `--ortho-lambda` | `0` for `loraatt`; `10.0` for B-32/B-16, `1.0` for L-14 with `loraatt_ortho` |
|
| 181 |
+
| `--finetuning-mode` | `loraatt` or `loraatt_ortho` |
|
| 182 |
+
|
| 183 |
+
---
|
| 184 |
+
|
| 185 |
+
## π¦ Datasets
|
| 186 |
+
|
| 187 |
+
We evaluate on 8 image classification benchmarks: **Cars Β· DTD Β· EuroSAT Β· GTSRB Β· MNIST Β· RESISC45 Β· SUN397 Β· SVHN**
|
| 188 |
+
|
| 189 |
+
For dataset preparation, follow the instructions in the [TTA repository](https://github.com/gortizji/tangent_task_arithmetic#datasets).
|
| 190 |
+
|
| 191 |
+
---
|
| 192 |
+
|
| 193 |
+
## π Citation
|
| 194 |
+
|
| 195 |
+
If you find this work useful, please cite:
|
| 196 |
+
|
| 197 |
+
```bibtex
|
| 198 |
+
@inproceedings{liu2026orthoreg,
|
| 199 |
+
title = {Understanding and Enforcing Weight Disentanglement in Task Arithmetic},
|
| 200 |
+
author = {Liu, Shangge and Yin, Yuehan and Wang, Lei and Fan, Qi and
|
| 201 |
+
Shi, Yinghuan and Li, Wenbin and Gao, Yang and Tao, Dacheng},
|
| 202 |
+
booktitle = {CVPR},
|
| 203 |
+
year = {2026}
|
| 204 |
+
}
|
| 205 |
+
```
|
| 206 |
+
|
| 207 |
+
---
|
| 208 |
+
|
| 209 |
+
## π¬ Acknowledgements
|
| 210 |
+
|
| 211 |
+
This codebase is built on top of [Task Arithmetic](https://github.com/mlfoundations/task_vectors), [Tangent Task Arithmetic](https://github.com/gortizji/tangent_task_arithmetic), and [Attention-Only Fine-tuning](https://github.com/kyrie-23/linear_task_arithmetic). We thank the authors for releasing their code.
|