Task Residual for Tuning Vision-Language Models

Tao Yu, Zhihe Lu, Xin Jin, Zhibo Chen, Xinchao Wang

Abstract

Adapting large-scale vision-language models (VLMs) like CLIP to specific downstream tasks often involves a trade-off between preserving pre-trained knowledge and learning task-specific features. Existing methods like Prompt Tuning and Adapter-style Tuning frequently struggle with "forgetting" or being overly biased toward the pre-trained prior. We present Task Residual Tuning (TaskRes), a simple yet effective approach that adds learnable residual parameters directly to the frozen text-based classifier. TaskRes decouples the prior knowledge from new task-specific knowledge, enabling efficient adaptation. Our experiments across 11 benchmark datasets demonstrate that TaskRes consistently outperforms state-of-the-art methods while offering significantly faster training times and better domain generalization.

Introduction

Large-scale Vision-Language Models (VLMs), such as CLIP, are trained on massive datasets of image-text pairs, acquiring a broad and robust "prior knowledge" of visual concepts. However, applying these models to specialized downstream tasks—ranging from fine-grained aircraft identification to satellite imagery analysis—requires efficient adaptation. This field, known as Efficient Transfer Learning (ETL), seeks to tune models with minimal data and compute.

Current ETL strategies primarily fall into two categories:

  1. Prompt Tuning (PT): This method replaces static text prompts with learnable vectors. While popular, PT can inadvertently distort the well-defined classification boundaries of the pre-trained model, leading to a loss of valuable prior knowledge.
  2. Adapter-style Tuning (AT): This involves adding transformation layers to the model's feature space. AT tends to be "prior-dependent," meaning it relies heavily on the existing feature representations. If the pre-trained model lacks a good initial representation for a niche task, the adapter often fails to explore the necessary new knowledge effectively.

Task Residual Tuning (TaskRes)

To overcome these limitations, we propose Task Residual Tuning (TaskRes). Unlike previous methods that modify inputs or intermediate features, TaskRes operates directly on the final text-based classifier—the embeddings generated by the VLM's text encoder.

Comparison of different tuning strategies for Vision-Language Models. TaskRes (d) adds an independent residual to the frozen classifier.

The core mechanism of TaskRes is elegantly simple. Given a frozen text embedding $t$ from the pre-trained VLM, we compute the new classifier $t'$ as: $$t' = t + \alpha x$$ where $x$ represents a set of learnable "task residual" parameters and $\alpha$ is a scaling factor. By keeping the original embedding $t$ frozen and making the residual $x$ independent of $t$, TaskRes explicitly decouples the "old" prior knowledge from the "new" task-specific knowledge. This allows the model to inherit the VLM's general understanding while providing the flexibility to learn specialized details. Implementation is remarkably straightforward, often requiring just a single additional line of code.

Experimental Evaluation

We evaluated TaskRes across a comprehensive suite of 11 benchmark datasets, covering general objects (ImageNet, Caltech101), fine-grained categories (OxfordPets, StanfordCars, Flowers102, Food101, FGVCAircraft), and specialized domains (SUN397, DTD, EuroSAT, UCF101).

Performance comparison of TaskRes (Ours) against CoOp, CLIP-Adapter, and Tip-Adapter-F across 11 datasets and varying shot counts.

Key Results

TaskRes consistently achieved state-of-the-art performance, outperforming established methods like CoOp and CLIP-Adapter. The gains were particularly pronounced on "hard" tasks where the pre-trained model's initial performance was low. For instance, on the EuroSAT satellite imagery dataset in a 1-shot setting, TaskRes improved accuracy by 23.71% over the zero-shot baseline.

Beyond raw accuracy, TaskRes demonstrated superior efficiency and robustness:

  • Training Speed: On 4-shot ImageNet, TaskRes required only 11 minutes to train, a nearly 11x speedup compared to the 121 minutes required for CoOp. This efficiency stems from not needing to backpropagate through the heavy text encoder during every training step.
  • Domain Generalization: When trained on ImageNet and tested on variants like ImageNet-Sketch or ImageNet-A (adversarial), TaskRes showed better out-of-distribution performance than prompt tuning, indicating it preserves the model's original robustness more effectively.
  • Residual-Difficulty Correlation: An intriguing finding is that the magnitude of the learned residual $x$ correlates with task difficulty. For tasks similar to the pre-training data (e.g., ImageNet), the residual remains small. For highly divergent tasks (e.g., EuroSAT), the model learns a significantly larger residual to bridge the gap.

Conclusion and Future Work

TaskRes offers a simple, "residual" fix for the challenges of tuning large VLMs. By decoupling prior and task-specific knowledge at the classifier level, it achieves high performance with minimal computational overhead.

While highly effective, TaskRes is not without limitations. In extremely low-shot settings (1-shot) on certain fine-grained datasets like OxfordPets, it can occasionally underperform the zero-shot baseline due to overfitting on very limited data. Future research could explore extending this residual concept to other foundation models and developing more formal methods for assessing task transfer difficulty.

Summary updated

BibTeX
@inproceedings{yu2022task,
  author = {Tao Yu and Zhihe Lu and Xin Jin and Zhibo Chen and Xinchao Wang},
  title = {{Task Residual for Tuning Vision-Language Models}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
}
Figure