{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/amortized-prompt-lightweight-fine-tuning-for","title":"Domain Prompt Learning for Efficiently Adapting CLIP to Unseen Domains","arxiv_id":"2111.12853","date":"2021-11-25","proceeding":null,"authors":["Xin Zhang","Shixiang Shane Gu","Yutaka Matsuo","Yusuke Iwasawa"],"abstract":"Domain generalization (DG) is a difficult transfer learning problem aiming to learn a generalizable model for unseen domains. Recent foundation models (FMs) are robust to many distribution shifts and, therefore, should substantially improve the performance of DG. In this work, we study generic ways to adopt CLIP, a Visual-Language Foundation Model, for DG problems in image classification. While ERM greatly improves the accuracy with bigger backbones and training datasets using standard DG benchmarks, fine-tuning FMs is not practical in many real-world situations. We propose Domain Prompt Learning (DPL) as a novel approach for domain inference in the form of conditional prompt generation. DPL achieved a significant accuracy improvement with only training a lightweight prompt generator (a three-layer MLP), whose parameter is of equivalent scale to the classification projector in the previous DG literature. Combining \\dplshort~with CLIP provides surprising performance, raising the accuracy of zero-shot CLIP from 73.7% to 79.3% on several standard datasets, namely PACS, VLCS, OfficeHome, and TerraIncognita. We hope the simplicity and success of our approach lead to broader adoption and analysis of foundation models in the domain generalization field. Our code is available at https://github.com/shogi880/DPLCLIP.","url_abs":"https://arxiv.org/abs/2111.12853v4","url_pdf":"https://arxiv.org/pdf/2111.12853v4.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"amortized-prompt-lightweight-fine-tuning-for","repo_url":"https://github.com/shogi880/DPLCLIP","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"domain-generalization","task_name":"Domain Generalization"},{"task_slug":"image-classification","task_name":"Image Classification"},{"task_slug":"prompt-learning","task_name":"Prompt Learning"},{"task_slug":"transfer-learning","task_name":"Transfer Learning"},{"task_slug":"zero-shot-learning","task_name":"Zero-Shot Learning"},{"task_slug":"image-classification","task_name":"image-classification"}],"methods":[{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"clip","method_name":"CLIP"},{"method_slug":"cosine-annealing","method_name":"Cosine Annealing"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"gpt-3","method_name":"GPT-3"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-cosine-annealing","method_name":"Linear Warmup With Cosine Annealing"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"weight-decay","method_name":"Weight Decay"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/transfer-learning-on-office-home","task":"Transfer Learning","dataset":"Office-Home","model":"APCLIP","rank_in_archive_order":1,"of":5,"metrics":{"Accuracy":"84.2"},"uses_additional_data":false}],"syntology":{"syntology_url":"https://syntology.ai/paper/2111.12853","atlas_url":"https://app.syntology.ai/?focus=2111.12853","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2111.12853"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/shogi880/DPLCLIP","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_draft_wrong":4,"ran":7,"ran_violates":1,"unverified":5},"by_repo_kind":{"official":{"samples":17,"ran":12,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":17,"samples":[{"code_sha256_prefix":"ce7990d7ad5821ff","entry":"Classifier","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/networks.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/networks.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"ce7990d7ad5821ff"}},{"code_sha256_prefix":"09762c09de098b26","entry":"configure_model","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/adapt_algorithms.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/adapt_algorithms.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"09762c09de098b26"}},{"code_sha256_prefix":"ee80cf467065076b","entry":"conv1x1","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/lib/big_transfer.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/lib/big_transfer.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"ee80cf467065076b"}},{"code_sha256_prefix":"f01b8d3901f0b289","entry":"conv3x3","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/lib/big_transfer.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/lib/big_transfer.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"f01b8d3901f0b289"}},{"code_sha256_prefix":"eeef10dc6caedb9c","entry":"copy_model_and_optimizer","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/adapt_algorithms.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/adapt_algorithms.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"eeef10dc6caedb9c"}},{"code_sha256_prefix":"53fac8d8d949e72b","entry":"get_test_records","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/model_selection.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/model_selection.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"53fac8d8d949e72b"}},{"code_sha256_prefix":"71a3a61ceed99bf3","entry":"hashable","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/lib/query.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/lib/query.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"71a3a61ceed99bf3"}},{"code_sha256_prefix":"2f8af5779e1edcb6","entry":"make_selector_fn","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/lib/query.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/lib/query.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"2f8af5779e1edcb6"}},{"code_sha256_prefix":"5f576ed342c48a0a","entry":"make_weights_for_balanced_classes","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/lib/misc.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/lib/misc.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"5f576ed342c48a0a"}},{"code_sha256_prefix":"196cab71d7129d62","entry":"remove_batch_norm_from_resnet","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/networks.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/networks.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"196cab71d7129d62"}},{"code_sha256_prefix":"18e820e42046bc45","entry":"split_dataset","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/lib/misc.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/lib/misc.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"18e820e42046bc45"}},{"code_sha256_prefix":"7023eb86801bb3a3","entry":"tf2th","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/lib/big_transfer.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/lib/big_transfer.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"7023eb86801bb3a3"}},{"code_sha256_prefix":"b0bc80b1655a6802","entry":"get_algorithm_class","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/adapt_algorithms.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/adapt_algorithms.py","link_basis":"plan_row","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"b0bc80b1655a6802"}},{"code_sha256_prefix":"d0ea85d74c20dea9","entry":"get_dataset_class","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/datasets.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/datasets.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"d0ea85d74c20dea9"}},{"code_sha256_prefix":"ede61a3f47f1cb21","entry":"multi_gpu_launcher","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/command_launchers.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/command_launchers.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"ede61a3f47f1cb21"}},{"code_sha256_prefix":"73f32252eedba6a4","entry":"num_environments","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/datasets.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/datasets.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"73f32252eedba6a4"}},{"code_sha256_prefix":"af3c9a80c8fd1f7a","entry":"print_row","repo":"shogi880/DPLCLIP","repo_kind":"official","path":"domainbed/lib/misc.py","file_url":"https://github.com/shogi880/DPLCLIP/blob/HEAD/domainbed/lib/misc.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"af3c9a80c8fd1f7a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}