{"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/advclip-downstream-agnostic-adversarial","title":"AdvCLIP: Downstream-agnostic Adversarial Examples in Multimodal Contrastive Learning","arxiv_id":"2308.07026","date":"2023-08-14","proceeding":null,"authors":["Ziqi Zhou","Shengshan Hu","Minghui Li","Hangtao Zhang","Yechao Zhang","Hai Jin"],"abstract":"Multimodal contrastive learning aims to train a general-purpose feature extractor, such as CLIP, on vast amounts of raw, unlabeled paired image-text data. This can greatly benefit various complex downstream tasks, including cross-modal image-text retrieval and image classification. Despite its promising prospect, the security issue of cross-modal pre-trained encoder has not been fully explored yet, especially when the pre-trained encoder is publicly available for commercial use. In this work, we propose AdvCLIP, the first attack framework for generating downstream-agnostic adversarial examples based on cross-modal pre-trained encoders. AdvCLIP aims to construct a universal adversarial patch for a set of natural images that can fool all the downstream tasks inheriting the victim cross-modal pre-trained encoder. To address the challenges of heterogeneity between different modalities and unknown downstream tasks, we first build a topological graph structure to capture the relevant positions between target samples and their neighbors. Then, we design a topology-deviation based generative adversarial network to generate a universal adversarial patch. By adding the patch to images, we minimize their embeddings similarity to different modality and perturb the sample distribution in the feature space, achieving unviersal non-targeted attacks. Our results demonstrate the excellent attack performance of AdvCLIP on two types of downstream tasks across eight datasets. We also tailor three popular defenses to mitigate AdvCLIP, highlighting the need for new defense mechanisms to defend cross-modal pre-trained encoders.","url_abs":"https://arxiv.org/abs/2308.07026v1","url_pdf":"https://arxiv.org/pdf/2308.07026v1.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":"advclip-downstream-agnostic-adversarial","repo_url":"https://github.com/cgcl-codes/advclip","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"contrastive-learning","task_name":"Contrastive Learning"},{"task_slug":null,"task_name":"Generative Adversarial Network"},{"task_slug":"image-classification","task_name":"Image Classification"},{"task_slug":"image-text-retrieval","task_name":"Image-text Retrieval"},{"task_slug":"text-retrieval","task_name":"Text Retrieval"},{"task_slug":"image-classification","task_name":"image-classification"}],"methods":[{"method_slug":"clip","method_name":"CLIP"},{"method_slug":"contrastive-learning","method_name":"Contrastive Learning"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2308.07026","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2308.07026"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+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/cgcl-codes/advclip","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":9,"ran_fixture":1,"ran_honours":1,"ran_draft_wrong":2,"ran_violates":1,"unverified":2},"by_repo_kind":{"official":{"samples":16,"ran":14,"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":"0daa5f9fe5b85ae3","entry":"CE","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/metrics.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/metrics.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":true,"mcp_get_code":{"code_sha256":"0daa5f9fe5b85ae3"}},{"code_sha256_prefix":"fb0541d3902f7b0c","entry":"KL","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/metrics.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/metrics.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":true,"mcp_get_code":{"code_sha256":"fb0541d3902f7b0c"}},{"code_sha256_prefix":"1e369e39c90cada6","entry":"accuracy","repo":"cgcl-codes/advclip","repo_kind":"official","path":"train_downstream_solo.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/train_downstream_solo.py","link_basis":"plan_row","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":"1e369e39c90cada6"}},{"code_sha256_prefix":"3a01df6a1dc9521d","entry":"clamp_patch","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/patch_utils.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/patch_utils.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":"3a01df6a1dc9521d"}},{"code_sha256_prefix":"299ed83aade55bae","entry":"fx_calc_map_label","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/evaluate.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/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":"299ed83aade55bae"}},{"code_sha256_prefix":"19a8a77e50cab4fd","entry":"fx_calc_recall","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/evaluate.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/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":"19a8a77e50cab4fd"}},{"code_sha256_prefix":"c2f0705ed8e6f7e6","entry":"gelu","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/model.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/model.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c2f0705ed8e6f7e6"}},{"code_sha256_prefix":"9bf455ab09372ab4","entry":"l1norm","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/model.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/model.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9bf455ab09372ab4"}},{"code_sha256_prefix":"be7c4a676b9f1e19","entry":"l2norm","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/model.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/model.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"be7c4a676b9f1e19"}},{"code_sha256_prefix":"e1d898daa31e30ff","entry":"make_print_to_file","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/evaluate.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/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":"e1d898daa31e30ff"}},{"code_sha256_prefix":"d5a0abdbf17edceb","entry":"mask_generation","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/patch_utils.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/patch_utils.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":"d5a0abdbf17edceb"}},{"code_sha256_prefix":"81e84201408ca9e3","entry":"patch_initialization","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/patch_utils.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/patch_utils.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":"81e84201408ca9e3"}},{"code_sha256_prefix":"f6dd2b488b69305c","entry":"test","repo":"cgcl-codes/advclip","repo_kind":"official","path":"train_downstream_solo.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/train_downstream_solo.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":"f6dd2b488b69305c"}},{"code_sha256_prefix":"55f1419d4d8c483c","entry":"transpose","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/nce.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/nce.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":true,"mcp_get_code":{"code_sha256":"55f1419d4d8c483c"}},{"code_sha256_prefix":"2c4ef32312957719","entry":"algorithm2","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/metrics.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/metrics.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":"2c4ef32312957719"}},{"code_sha256_prefix":"54b175c46812e410","entry":"info_nce","repo":"cgcl-codes/advclip","repo_kind":"official","path":"utils/nce.py","file_url":"https://github.com/cgcl-codes/advclip/blob/HEAD/utils/nce.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":"54b175c46812e410"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}