{"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/one-prompt-word-is-enough-to-boost","title":"One Prompt Word is Enough to Boost Adversarial Robustness for Pre-trained Vision-Language Models","arxiv_id":"2403.01849","date":"2024-03-04","proceeding":"CVPR 2024 1","authors":["Lin Li","Haoyan Guan","Jianing Qiu","Michael Spratling"],"abstract":"Large pre-trained Vision-Language Models (VLMs) like CLIP, despite having remarkable generalization ability, are highly vulnerable to adversarial examples. This work studies the adversarial robustness of VLMs from the novel perspective of the text prompt instead of the extensively studied model weights (frozen in this work). We first show that the effectiveness of both adversarial attack and defense are sensitive to the used text prompt. Inspired by this, we propose a method to improve resilience to adversarial attacks by learning a robust text prompt for VLMs. The proposed method, named Adversarial Prompt Tuning (APT), is effective while being both computationally and data efficient. Extensive experiments are conducted across 15 datasets and 4 data sparsity schemes (from 1-shot to full training data settings) to show APT's superiority over hand-engineered prompts and other state-of-the-art adaption methods. APT demonstrated excellent abilities in terms of the in-distribution performance and the generalization under input distribution shift and across datasets. Surprisingly, by simply adding one learned word to the prompts, APT can significantly boost the accuracy and robustness (epsilon=4/255) over the hand-engineered prompts by +13% and +8.5% on average respectively. The improvement further increases, in our most effective setting, to +26.4% for accuracy and +16.7% for robustness. Code is available at https://github.com/TreeLLi/APT.","url_abs":"https://arxiv.org/abs/2403.01849v1","url_pdf":"https://arxiv.org/pdf/2403.01849v1.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":"one-prompt-word-is-enough-to-boost","repo_url":"https://github.com/treelli/apt","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"adversarial-attack","task_name":"Adversarial Attack"},{"task_slug":"adversarial-robustness","task_name":"Adversarial Robustness"}],"methods":[{"method_slug":"clip","method_name":"CLIP"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2403.01849","atlas_url":"https://app.syntology.ai/?focus=2403.01849","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2403.01849"}},"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/treelli/apt","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"deterministic:regex_extraction","url":"https://github.com/TreeLLi/APT","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":4,"ran_fixture":1,"unverified":1},"by_repo_kind":{"official":{"samples":6,"ran":5,"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":0,"samples":[{"code_sha256_prefix":"56f50ad83ac3e71c","entry":"CWLoss","repo":"TreeLLi/APT","repo_kind":"official","path":"apt/evaluate.py","file_url":"https://github.com/TreeLLi/APT/blob/HEAD/apt/evaluate.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"56f50ad83ac3e71c"}},{"code_sha256_prefix":"b0f936d4d6ae3b8c","entry":"accuracy","repo":"TreeLLi/APT","repo_kind":"official","path":"apt/utils.py","file_url":"https://github.com/TreeLLi/APT/blob/HEAD/apt/utils.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b0f936d4d6ae3b8c"}},{"code_sha256_prefix":"0653de8feae18a9b","entry":"auto_find_path","repo":"TreeLLi/APT","repo_kind":"official","path":"apt/OODRB/cifar.py","file_url":"https://github.com/TreeLLi/APT/blob/HEAD/apt/OODRB/cifar.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0653de8feae18a9b"}},{"code_sha256_prefix":"b2c121009a4b58c4","entry":"input_grad","repo":"TreeLLi/APT","repo_kind":"official","path":"apt/evaluate.py","file_url":"https://github.com/TreeLLi/APT/blob/HEAD/apt/evaluate.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b2c121009a4b58c4"}},{"code_sha256_prefix":"c2be82a99f878e8c","entry":"perturb","repo":"TreeLLi/APT","repo_kind":"official","path":"apt/evaluate.py","file_url":"https://github.com/TreeLLi/APT/blob/HEAD/apt/evaluate.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c2be82a99f878e8c"}},{"code_sha256_prefix":"c47aa9e5b049a11d","entry":"build_model","repo":"TreeLLi/APT","repo_kind":"official","path":"apt/clip/model.py","file_url":"https://github.com/TreeLLi/APT/blob/HEAD/apt/clip/model.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":true,"mcp_get_code":{"code_sha256":"c47aa9e5b049a11d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}