arXiv:2610.30680cs.CVOct 2026

Manuscript Offprint

arXiv:2610.30680

Zero-Shot Domain Generalization via Domain Prompt Learning

Shiming Chen, Shuhuang Chen, Salman Khan, Fahad Shahbaz Khan

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Domain generalization (DG) aims to improve the generalization of the model to any unseen domains. Targeting this goal, existing DG methods mainly focus on learning domain-invariant features or prompts from the given source domains. However, these methods rely on source-domain data, and collecting and annotating large-scale single- or multi-source datasets is often infeasible, limiting the practical applicability of DG. To tackle this challenge, we propose Domain Prompt Learning (DoP), a method built on a large vision-language model (e.g., CLIP) for zero-shot domain generalization, which recognizes unseen classes in unseen target domains without access to source-domain data. DoP essentially learns the target domain knowledge via prompt both in text and visual modalities to overcome the domain shift in text-visual modalities under the test-time adaptation formulation. Specifically, DoP first takes text domain learning (TDL) to simulate various distribution shifts by learning diverse style tokens implicitly in the text space with inter-style diversity loss and intra-style consistency loss. Subsequently, DoP employs visual domain learning (VDL) to further refine the target-domain-relevant style token generated by TDL by making use of the test visual data with self-supervised learning. Extensive experiments on popular DG benchmark datasets (e.g., PACS, VLCS, OfficeHome, and DomainNet) and ImageNet show that our DoP consistently outperforms the state-of-the-art DG approaches. Codes are available at: https://github.com/shiming-chen/DoP.

Keywords Domain Generalization · Visual-Language Model · Domain Prompt Learning · Zero-Shot Domain Generalization · Zero-Shot Learning

1 Introduction and Motivation

Early machine learning models assume that training data and test data are independent and identical distributions Quiñonero-Candela et al (2008); Chen et al (2021), resulting in weak robust to significant distribution shifts between training and test distribution, e.g., style, backgrounds or day-to-night shifts. To address this problem, domain generalization (DG) was introduced Blanchard et al (2011); Zhou et al (2023a), assuming that a model is trained on data from one or multiple source domains and generalizes well to unseen target domains or styles. As shown in Fig. 1(a), given source domains containing images of dogs in sketch, cartoon, and painting styles, DG aims to learn a model that can recognize dogs in natural images or photographs. Enhancing the generalization ability of machine learning models is important in both industry and academic fields, DG has received much attention recently Wang et al (2023a).

Standard DG methods aim to learn domain-invariant features or prompts from the given source domain data to tackle domain shift in the visual modality, as shown in Fig 1 (c). Early DG methods learn domain-invariant features to improve model generalization to target domains using various training strategies, such as data augmentation Chattopadhyay et al (2020); Nam et al (2021); Zhou et al (2020); Nam et al (2021); Nuriel et al (2021), cross-domain feature alignment methods Ganin et al (2016); Li et al (2018c,b), decomposing domain-specific and domain-invariant knowledge Piratla et al (2020); Chattopadhyay et al (2020); Lv et al (2022), meta-learning Balaji et al (2018); Dou et al (2019); Zhang et al (2022), and ensemble learning Cha et al (2021); Zhou et al (2021). Although these methods achieve significant progress in small datasets, they cannot well generalize to large-scale datasets, e.g., different variants of ImageNet Deng et al (2009).

Corresponding author: Shiming Chen. Email: gchenshiming@gmail.com

Address(es) of author(s) should be given

1 INTRODUCTION AND MOTIVATION

Figure

(a) Standard Domain Generalization

Figure

(b) Zero-Shot Domain Generalization

Figure

(c) Distribution Shift in Visual Modality

Figure

(d) Distribution Shift in Text-Visual Modalities

Figure

Fig. 1: Standard Domain Generalization (DG) vs Zero-Shot Domain Generalization (ZSDG). (a)(c) Standard DG methods mainly learn the domain-invariant features or prompts from the given source domains to tackle domain shift in visual modality. They are infeasible to collect and annotate large-scale source domain data for training, resulting in limited applications of DG in realistic scenarios. (b)(d) The ZSDG method recognizes unseen classes in the target/unseen domains without data in the source domain by overcoming domain shift in text-visual modalities.

Recently, large vision-language models (VLMs), such as CLIP Radford et al (2021) and ALIGN Jia et al (2021), have been trained on large-scale image-text data and have demonstrated strong domain generalization and zero-shot learning capabilities on downstream tasks. Accordingly, VLM reforms the DG formulation and obtains new state-of-the-art generalization performance Baliah et al (2023); Addepalli et al (2024). There are two categories of methods to bring VLM into DG, including prompt learning and fine-tuning VLM. For example, Zhou et al (2022b) introduces CoOp to explore the concept of prompt learning for automating prompt engineering via fine-tuning a few prompt tokens. Subsequently, he extends CoOp by further learning a lightweight neural network to generate an input-conditional token for each image and improve model generalization Zhou et al (2022a). In contrast, Jia et al (2022) proposed visual prompt tuning for fine-tuning VLM. Cha et al (2022) re-formulated the DG objective using mutual information with the Oracle model to any possible domain. Bai et al (2024) re-framed the prompt learning framework from a generative perspective and propose a simple yet efficient method for DG.

We can find that the above methods access source domain data (i.e., visual data in some domains shared same classes in the target domain) for model optimization. However, these methods face three major limitations in realistic scenarios: i) it is unclear which source domains are ideal and how many source domains are sufficient for model learning since unseen domains are arbitrary in DG; ii) it is costly and infeasible to collect and annotate large-scale source domain data for training; iii) Lots of classes cannot be collected in advance, especially for the new or scarce classes in the real world. Naturally, it raises a new task, i.e., zero-shot domain generalization (ZSDG), which recognizes unseen classes in unseen domains without source domain data, as shown in Fig. 1 (b).

The potential solution for ZSDG is directly making use of the zero-shot learning capacity of VLMs (e.g., CLIP) without accessing visual data of unseen classes in source data for training. Thus, the rest key task is how to discover the domain knowledge to improve the domain generalization of VLMs. This raises the challenge of distribution shift in text-visual modalities in the unseen domain (as shown in Fig 1 (d)), which is more challenging than the distribution shift in the visual modality of standard DG.

To tackle this challenge, our intuitive insight is to simultaneously discover target domain knowledge both in text and visual modalities under the test-time adaptation formulation Sun et al (2020); Shu et al (2022); Feng et al (2023). In the text modality, we simulate diverse distribution shifts through prompts that synthesize diverse domain knowledge. In the visual modality, we can explicitly discover the target domain knowledge via prompt by making use of test visual information with self-supervised learning during testing. More importantly, the domain knowledge learned in text modality can be further refined in the visual modality jointly.

In light of the above observations, we propose a novel Domain Prompt learning (dubbed DoP) for zero-shot domain generalization. DoP consists of two key modules to learn the domain prompt, including text domain learning (TDL) and visual domain learning (VDL). In the first stage, TDL simulates various distribution shifts via a prompt in the text space by synthesizing diverse domains knowledge, i.e., styles token generation using inter-style diversity loss and intra-style consistency loss and for optimization, and selects the most relevant style token ( S∗S^{*}) from the generated style tokens based on the test image. In the second stage, VDL refines the selected style token S∗S^{*} using the test image and domain prompt (i.e., "A S∗S^{*} style of a [class]" via self-supervised learning. Unlike PromptStyler Cho et al (2023), which uses all synthesized style features to construct a fixed domain-generalizable classifier, DoP treats the learned style tokens as candidate domain prompts and dynamically selects and visually refines the target-relevant token for each test image. Finally, DoP takes the refined domain prompt to predict the classes of test images using CLIP prediction Radford et al (2021). Extensive experiments demonstrate the effectiveness of our method.

The main contributions are summarized as follows:

– We introduce domain prompt learning, dubbed as DoP, which learns the domain knowledge both in text and visual spaces to tackle the domain shift in text-visual modalities of ZSDG.

– We deploy TDL to discover the domain knowledge via a prompt in the text space using inter-style diversity loss and intra-style consistency loss. Meanwhile, we design VDL to further refine the target-domain-relevant style token generated by TDL via self-supervised learning during testing. Thus, DoP can implicitly and explicitly learn the domain knowledge with the text and visual supervision.

– Extensive experimental results on four widely used DG benchmarks (i.e., PACS, VLCS, OfficeHome, and DomainNet) and ImageNet, demonstrate that our DoP learns the domain knowledge for effective ZSDG, thus leading to competitive performance over the current state-of-the-art methods.

References (58)