{"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/fa-forced-prompt-learning-of-vision-language","title":"FA: Forced Prompt Learning of Vision-Language Models for Out-of-Distribution Detection","arxiv_id":"2507.04511","date":"2025-07-06","proceeding":null,"authors":["Xinhua Lu","Runhe Lai","Yanqi Wu","Kanghao Chen","Wei-Shi Zheng","Ruixuan Wang"],"abstract":"Pre-trained vision-language models (VLMs) have advanced out-of-distribution (OOD) detection recently. However, existing CLIP-based methods often focus on learning OOD-related knowledge to improve OOD detection, showing limited generalization or reliance on external large-scale auxiliary datasets. In this study, instead of delving into the intricate OOD-related knowledge, we propose an innovative CLIP-based framework based on Forced prompt leArning (FA), designed to make full use of the In-Distribution (ID) knowledge and ultimately boost the effectiveness of OOD detection. Our key insight is to learn a prompt (i.e., forced prompt) that contains more diversified and richer descriptions of the ID classes beyond the textual semantics of class labels. Specifically, it promotes better discernment for ID images, by forcing more notable semantic similarity between ID images and the learnable forced prompt. Moreover, we introduce a forced coefficient, encouraging the forced prompt to learn more comprehensive and nuanced descriptions of the ID classes. In this way, FA is capable of achieving notable improvements in OOD detection, even when trained without any external auxiliary datasets, while maintaining an identical number of trainable parameters as CoOp. Extensive empirical evaluations confirm our method consistently outperforms current state-of-the-art methods. Code is available at https://github.com/0xFAFA/FA.","url_abs":"https://arxiv.org/abs/2507.04511v1","url_pdf":"https://arxiv.org/pdf/2507.04511v1.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":"fa-forced-prompt-learning-of-vision-language","repo_url":"https://github.com/0xfafa/fa","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"ood-detection","task_name":"Out of Distribution (OOD) Detection"},{"task_slug":"out-of-distribution-detection","task_name":"Out-of-Distribution Detection"},{"task_slug":"prompt-learning","task_name":"Prompt Learning"},{"task_slug":"semantic-similarity","task_name":"Semantic Similarity"},{"task_slug":"semantic-textual-similarity","task_name":"Semantic Textual Similarity"}],"methods":[{"method_slug":"coop","method_name":"CoOp"},{"method_slug":"dfa","method_name":"FA"},{"method_slug":"focus","method_name":"Focus"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2507.04511","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2507.04511"}},"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":"deterministic:regex_extraction","url":"https://github.com/0xFAFA/FA","reach":{"status":"ok"}}],"summary":{"ran_draft_wrong":3,"unverified":6},"by_repo_kind":{"official":{"samples":9,"ran":3,"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":9,"samples":[{"code_sha256_prefix":"98f385d847636a3e","entry":"basic_clean","repo":"0xFAFA/FA","repo_kind":"official","path":"clip/simple_tokenizer.py","file_url":"https://github.com/0xFAFA/FA/blob/HEAD/clip/simple_tokenizer.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"98f385d847636a3e"}},{"code_sha256_prefix":"d919ae32e5e4e616","entry":"get_pairs","repo":"0xFAFA/FA","repo_kind":"official","path":"clip/simple_tokenizer.py","file_url":"https://github.com/0xFAFA/FA/blob/HEAD/clip/simple_tokenizer.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":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d919ae32e5e4e616"}},{"code_sha256_prefix":"9542161e9640b858","entry":"whitespace_clean","repo":"0xFAFA/FA","repo_kind":"official","path":"clip/simple_tokenizer.py","file_url":"https://github.com/0xFAFA/FA/blob/HEAD/clip/simple_tokenizer.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9542161e9640b858"}},{"code_sha256_prefix":"f3830274a7e18d5e","entry":"build_model","repo":"0xFAFA/FA","repo_kind":"official","path":"clip/model_origin.py","file_url":"https://github.com/0xFAFA/FA/blob/HEAD/clip/model_origin.py","link_basis":"plan_row","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f3830274a7e18d5e"}},{"code_sha256_prefix":"3116a18e959b946d","entry":"build_model","repo":"0xFAFA/FA","repo_kind":"official","path":"clip/model.py","file_url":"https://github.com/0xFAFA/FA/blob/HEAD/clip/model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3116a18e959b946d"}},{"code_sha256_prefix":"f2a0a5061e7c204e","entry":"cls_acc","repo":"0xFAFA/FA","repo_kind":"official","path":"utils.py","file_url":"https://github.com/0xFAFA/FA/blob/HEAD/utils.py","link_basis":"plan_row","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f2a0a5061e7c204e"}},{"code_sha256_prefix":"5de6943ed326286d","entry":"get_original_text_features","repo":"0xFAFA/FA","repo_kind":"official","path":"model.py","file_url":"https://github.com/0xFAFA/FA/blob/HEAD/model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5de6943ed326286d"}},{"code_sha256_prefix":"db64af1ba3479e8d","entry":"load","repo":"0xFAFA/FA","repo_kind":"official","path":"clip/clip.py","file_url":"https://github.com/0xFAFA/FA/blob/HEAD/clip/clip.py","link_basis":"plan_row","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"db64af1ba3479e8d"}},{"code_sha256_prefix":"dcbdc3602358ba4d","entry":"trm_single_image","repo":"0xFAFA/FA","repo_kind":"official","path":"utils.py","file_url":"https://github.com/0xFAFA/FA/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"dcbdc3602358ba4d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}