{"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/gallop-learning-global-and-local-prompts-for","title":"GalLoP: Learning Global and Local Prompts for Vision-Language Models","arxiv_id":"2407.01400","date":"2024-07-01","proceeding":null,"authors":["Marc Lafon","Elias Ramzi","Clément Rambour","Nicolas Audebert","Nicolas Thome"],"abstract":"Prompt learning has been widely adopted to efficiently adapt vision-language models (VLMs), e.g. CLIP, for few-shot image classification. Despite their success, most prompt learning methods trade-off between classification accuracy and robustness, e.g. in domain generalization or out-of-distribution (OOD) detection. In this work, we introduce Global-Local Prompts (GalLoP), a new prompt learning method that learns multiple diverse prompts leveraging both global and local visual features. The training of the local prompts relies on local features with an enhanced vision-text alignment. To focus only on pertinent features, this local alignment is coupled with a sparsity strategy in the selection of the local features. We enforce diversity on the set of prompts using a new ``prompt dropout'' technique and a multiscale strategy on the local prompts. GalLoP outperforms previous prompt learning methods on accuracy on eleven datasets in different few shots settings and with various backbones. Furthermore, GalLoP shows strong robustness performances in both domain generalization and OOD detection, even outperforming dedicated OOD detection methods. Code and instructions to reproduce our results: https://github.com/MarcLafon/gallop.","url_abs":"https://arxiv.org/abs/2407.01400v2","url_pdf":"https://arxiv.org/pdf/2407.01400v2.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":"gallop-learning-global-and-local-prompts-for","repo_url":"https://github.com/marclafon/gallop","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"diversity","task_name":"Diversity"},{"task_slug":"domain-generalization","task_name":"Domain Generalization"},{"task_slug":"few-shot-image-classification","task_name":"Few-Shot Image Classification"},{"task_slug":"image-classification","task_name":"Image Classification"},{"task_slug":"ood-detection","task_name":"Out of Distribution (OOD) Detection"},{"task_slug":"prompt-learning","task_name":"Prompt Learning"},{"task_slug":"image-classification","task_name":"image-classification"}],"methods":[{"method_slug":"clip","method_name":"CLIP"},{"method_slug":"focus","method_name":"Focus"},{"method_slug":"set","method_name":"SET"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2407.01400","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2407.01400"}},"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/marclafon/gallop","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":5},"by_repo_kind":{"official":{"samples":5,"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":"88e16a39c9e58cac","entry":"boolean_flags","repo":"marclafon/gallop","repo_kind":"official","path":"gallop/lib/boolean_flags.py","file_url":"https://github.com/marclafon/gallop/blob/HEAD/gallop/lib/boolean_flags.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":"88e16a39c9e58cac"}},{"code_sha256_prefix":"7fbc09d5e2a42c50","entry":"float_range","repo":"marclafon/gallop","repo_kind":"official","path":"gallop/lib/float_range.py","file_url":"https://github.com/marclafon/gallop/blob/HEAD/gallop/lib/float_range.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":"7fbc09d5e2a42c50"}},{"code_sha256_prefix":"7b841db2bef1b7e4","entry":"get_clip_hyperparams","repo":"marclafon/gallop","repo_kind":"official","path":"gallop/lib/get_clip_hyperparams.py","file_url":"https://github.com/marclafon/gallop/blob/HEAD/gallop/lib/get_clip_hyperparams.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":"7b841db2bef1b7e4"}},{"code_sha256_prefix":"39a56788b60da1ce","entry":"is_valid_file","repo":"marclafon/gallop","repo_kind":"official","path":"gallop/datasets/imagenet.py","file_url":"https://github.com/marclafon/gallop/blob/HEAD/gallop/datasets/imagenet.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":"39a56788b60da1ce"}},{"code_sha256_prefix":"23d0707685a2d89b","entry":"load_json","repo":"marclafon/gallop","repo_kind":"official","path":"gallop/lib/json_utils.py","file_url":"https://github.com/marclafon/gallop/blob/HEAD/gallop/lib/json_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":"23d0707685a2d89b"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}