Skip to main content
QUICK REVIEW

[Paper Review] Prompt Vision Transformer for Domain Generalization

Zangwei Zheng, Xiangyu Yue|arXiv (Cornell University)|Aug 18, 2022
Domain Adaptation and Few-Shot LearningComputer Science16 citations
TL;DR

This paper proposes DoPrompt, a novel domain generalization method for Vision Transformers that uses domain-specific prompts and a prompt adapter to improve zero-shot generalization to unseen domains. By learning domain prompts during training and dynamically adapting them at inference via a domain adapter, DoPrompt achieves 1.4% average accuracy gain over SOTA with ViT, outperforming previous methods by 3.5× in improvement magnitude.

ABSTRACT

Though vision transformers (ViTs) have exhibited impressive ability for representation learning, we empirically find that they cannot generalize well to unseen domains with previous domain generalization algorithms. In this paper, we propose a novel approach DoPrompt based on prompt learning to embed the knowledge of source domains in domain prompts for target domain prediction. Specifically, domain prompts are prepended before ViT input tokens from the corresponding source domain. Each domain prompt learns domain-specific knowledge efficiently since it is optimized only for one domain. Meanwhile, we train a prompt adapter to produce a suitable prompt for each input image based on the learned source domain prompts. At test time, the adapted prompt generated by the prompt adapter can exploit the similarity between the feature of the out-of-domain image and source domains to properly integrate the source domain knowledge. Extensive experiments are conducted on four benchmark datasets. Our approach achieves 1.4% improvements in the averaged accuracy, which is 3.5 times the improvement of the state-of-the-art algorithm with a ViT backbone.

Motivation & Objective

  • To address the poor domain generalization performance of Vision Transformers under domain shift.
  • To improve zero-shot generalization by learning domain-specific knowledge from source domains.
  • To develop a mechanism that adaptively combines source domain knowledge for unseen target domains at inference time.
  • To overcome limitations of prior domain generalization methods that use only partial network parameters or static ensembling.
  • To enable effective prompt-based adaptation without fine-tuning the ViT backbone.

Proposed method

  • Prepend domain-specific prompts to image patch tokens during training, allowing each prompt to learn domain-specific knowledge via self-attention.
  • Train a prompt adapter network that takes the input image's features and generates a weighted combination of source domain prompts for inference.
  • Optimize the prompt adapter using two losses: one to distinguish domain features and another to improve prediction accuracy on the target domain.
  • Use the adapted prompt at test time to dynamically integrate knowledge from multiple source domains based on domain similarity.
  • Fine-tune the entire model end-to-end, including the prompt adapter and domain prompts, to improve generalization.
  • Leverage the self-attention mechanism of ViTs to allow prompt tokens to interact with all layers, enabling rich feature understanding.

Experimental results

Research questions

  • RQ1Can prompt learning effectively capture domain-specific knowledge in Vision Transformers for domain generalization?
  • RQ2Does a learnable prompt adapter improve zero-shot generalization by dynamically combining source domain knowledge?
  • RQ3How does DoPrompt compare to SOTA methods in terms of accuracy and generalization gain when using ViT backbones?
  • RQ4To what extent do domain prompts and the prompt adapter contribute to performance, and are they both necessary?
  • RQ5Can the prompt adapter learn to reflect domain similarity between source and target domains?

Key findings

  • DoPrompt achieves a 1.4% average accuracy improvement over the SOTA baseline with ViT-Base, which is 3.5× higher than the previous best improvement.
  • The prompt adapter significantly improves performance, with a 1.2% drop in average accuracy when removed (76.0% → 74.8% on OfficeHome).
  • The ablation study confirms both the domain prompt and prompt adapter components are essential, with performance dropping by 1.7% when domain prompts are removed.
  • The prompt adapter learns to assign higher weights to source domains that are more similar to the target domain, as shown in weight analysis (e.g., Art domain is prioritized for Clipart target).
  • Using only prompt tuning without fine-tuning the backbone leads to a 2.0% accuracy drop (74.0% vs. 76.0%), indicating full fine-tuning is necessary.
  • The adapted prompt consistently outperforms individual source domain prompts on all target domains, confirming the adapter's ability to generate superior, context-aware prompts.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.