{"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/test-time-prompt-tuning-for-zero-shot","title":"Test-Time Prompt Tuning for Zero-Shot Generalization in Vision-Language Models","arxiv_id":"2209.07511","date":"2022-09-15","proceeding":null,"authors":["Manli Shu","Weili Nie","De-An Huang","Zhiding Yu","Tom Goldstein","Anima Anandkumar","Chaowei Xiao"],"abstract":"Pre-trained vision-language models (e.g., CLIP) have shown promising zero-shot generalization in many downstream tasks with properly designed text prompts. Instead of relying on hand-engineered prompts, recent works learn prompts using the training data from downstream tasks. While effective, training on domain-specific data reduces a model's generalization capability to unseen new domains. In this work, we propose test-time prompt tuning (TPT), a method that can learn adaptive prompts on the fly with a single test sample. For image classification, TPT optimizes the prompt by minimizing the entropy with confidence selection so that the model has consistent predictions across different augmented views of each test sample. In evaluating generalization to natural distribution shifts, TPT improves the zero-shot top-1 accuracy of CLIP by 3.6% on average, surpassing previous prompt tuning approaches that require additional task-specific training data. In evaluating cross-dataset generalization with unseen categories, TPT performs on par with the state-of-the-art approaches that use additional training data. Project page: https://azshue.github.io/TPT.","url_abs":"https://arxiv.org/abs/2209.07511v1","url_pdf":"https://arxiv.org/pdf/2209.07511v1.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":"test-time-prompt-tuning-for-zero-shot","repo_url":"https://github.com/azshue/TPT","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"image-classification","task_name":"Image Classification"},{"task_slug":"zero-shot-generalization","task_name":"Zero-shot Generalization"},{"task_slug":"image-classification","task_name":"image-classification"}],"methods":[{"method_slug":"clip","method_name":"CLIP"},{"method_slug":"test","method_name":"Test"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2209.07511","atlas_url":"https://app.syntology.ai/?focus=2209.07511","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2209.07511"}},"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/azshue/TPT","reach":null}],"summary":{"ran_draft_wrong":3,"ran_honours":1,"unverified":2},"by_repo_kind":{"official":{"samples":6,"ran":4,"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":"441ae80dd4f616f3","entry":"avg_entropy","repo":"azshue/TPT","repo_kind":"official","path":"tpt_classification.py","file_url":"https://github.com/azshue/TPT/blob/HEAD/tpt_classification.py","link_basis":"first_harvest_node","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":"441ae80dd4f616f3"}},{"code_sha256_prefix":"79e6e33a614be38a","entry":"avg_entropy","repo":"azshue/TPT","repo_kind":"official","path":"tpt_classification.py","file_url":"https://github.com/azshue/TPT/blob/HEAD/tpt_classification.py","link_basis":"first_harvest_node","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":"79e6e33a614be38a"}},{"code_sha256_prefix":"3ce4d11e58de02ad","entry":"select_confident_samples","repo":"azshue/TPT","repo_kind":"official","path":"tpt_classification.py","file_url":"https://github.com/azshue/TPT/blob/HEAD/tpt_classification.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3ce4d11e58de02ad"}},{"code_sha256_prefix":"93433d4c63e62457","entry":"select_confident_samples","repo":"azshue/TPT","repo_kind":"official","path":"tpt_classification.py","file_url":"https://github.com/azshue/TPT/blob/HEAD/tpt_classification.py","link_basis":"first_harvest_node","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":"93433d4c63e62457"}},{"code_sha256_prefix":"631c70c26c0fcedf","entry":"test_time_tuning","repo":"azshue/TPT","repo_kind":"official","path":"tpt_classification.py","file_url":"https://github.com/azshue/TPT/blob/HEAD/tpt_classification.py","link_basis":"first_harvest_node","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":"631c70c26c0fcedf"}},{"code_sha256_prefix":"d9c8e40aaeb631a8","entry":"test_time_tuning","repo":"azshue/TPT","repo_kind":"official","path":"tpt_classification.py","file_url":"https://github.com/azshue/TPT/blob/HEAD/tpt_classification.py","link_basis":"first_harvest_node","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":"d9c8e40aaeb631a8"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}