{"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/robust-fine-tuning-of-zero-shot-models-via","title":"Robust Fine-tuning of Zero-shot Models via Variance Reduction","arxiv_id":"2411.06966","date":"2024-11-11","proceeding":null,"authors":["Beier Zhu","Jiequan Cui","Hanwang Zhang"],"abstract":"When fine-tuning zero-shot models like CLIP, our desideratum is for the fine-tuned model to excel in both in-distribution (ID) and out-of-distribution (OOD). Recently, ensemble-based models (ESM) have been shown to offer significant robustness improvement, while preserving high ID accuracy. However, our study finds that ESMs do not solve the ID-OOD trade-offs: they achieve peak performance for ID and OOD accuracy at different mixing coefficients. When optimized for OOD accuracy, the ensemble model exhibits a noticeable decline in ID accuracy, and vice versa. In contrast, we propose a sample-wise ensembling technique that can simultaneously attain the best ID and OOD accuracy without the trade-offs. Specifically, we construct a Zero-Shot Failure (ZSF) set containing training samples incorrectly predicted by the zero-shot model. For each test sample, we calculate its distance to the ZSF set and assign a higher weight to the fine-tuned model in the ensemble if the distance is small. We term our method Variance Reduction Fine-tuning (VRF), as it effectively reduces the variance in ensemble predictions, thereby decreasing residual error. On ImageNet and five derived distribution shifts, our VRF further improves the OOD accuracy by 1.5 - 2.0 pp over the ensemble baselines while maintaining or increasing ID accuracy. VRF achieves similar large robustness gains (0.9 - 3.1 pp) on other distribution shifts benchmarks. Codes are available in https://github.com/BeierZhu/VRF.","url_abs":"https://arxiv.org/abs/2411.06966v1","url_pdf":"https://arxiv.org/pdf/2411.06966v1.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":"robust-fine-tuning-of-zero-shot-models-via","repo_url":"https://github.com/beierzhu/vrf","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[],"methods":[{"method_slug":"clip","method_name":"CLIP"},{"method_slug":"set","method_name":"SET"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2411.06966","atlas_url":"https://app.syntology.ai/?focus=2411.06966","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2411.06966"}},"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":"deterministic:regex_extraction","url":"https://github.com/BeierZhu/VRF","reach":{"status":"ok"}},{"provenance":"deterministic:regex_extraction","url":"https://github.com/MadryLab/BREEDS-Benchmarks","reach":{"status":"ok"}},{"provenance":"deterministic:regex_extraction","url":"https://github.com/modestyachts/ImageNetV2","reach":null},{"provenance":"deterministic:regex_extraction","url":"https://github.com/hendrycks/imagenet-r","reach":null},{"provenance":"deterministic:regex_extraction","url":"https://github.com/HaohanWang/ImageNet-Sketch","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/beierzhu/vrf","reach":{"status":"ok"}}],"summary":{"ran_draft_wrong":5,"ran":1,"ran_fixture":1,"unverified":4},"by_repo_kind":{"official":{"samples":11,"ran":7,"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":11,"samples":[{"code_sha256_prefix":"98f385d847636a3e","entry":"basic_clean","repo":"BeierZhu/VRF","repo_kind":"official","path":"clip/tokenizer.py","file_url":"https://github.com/BeierZhu/VRF/blob/HEAD/clip/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":"6d77ee840479c381","entry":"convert","repo":"BeierZhu/VRF","repo_kind":"official","path":"src/datasets/cifar10.py","file_url":"https://github.com/BeierZhu/VRF/blob/HEAD/src/datasets/cifar10.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6d77ee840479c381"}},{"code_sha256_prefix":"d919ae32e5e4e616","entry":"get_pairs","repo":"BeierZhu/VRF","repo_kind":"official","path":"clip/tokenizer.py","file_url":"https://github.com/BeierZhu/VRF/blob/HEAD/clip/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":"b1e9e0d3d7d7e615","entry":"maybe_dictionarize","repo":"BeierZhu/VRF","repo_kind":"official","path":"src/datasets/common.py","file_url":"https://github.com/BeierZhu/VRF/blob/HEAD/src/datasets/common.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":"b1e9e0d3d7d7e615"}},{"code_sha256_prefix":"9fbea808db47dc66","entry":"project_logits","repo":"BeierZhu/VRF","repo_kind":"official","path":"src/datasets/cifar10.py","file_url":"https://github.com/BeierZhu/VRF/blob/HEAD/src/datasets/cifar10.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9fbea808db47dc66"}},{"code_sha256_prefix":"9542161e9640b858","entry":"whitespace_clean","repo":"BeierZhu/VRF","repo_kind":"official","path":"clip/tokenizer.py","file_url":"https://github.com/BeierZhu/VRF/blob/HEAD/clip/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":"32a969e1f370ed34","entry":"wiseft_merge","repo":"beierzhu/vrf","repo_kind":"official","path":"src/models/modeling.py","file_url":"https://github.com/beierzhu/vrf/blob/HEAD/src/models/modeling.py","link_basis":"first_harvest_node","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":"32a969e1f370ed34"}},{"code_sha256_prefix":"4e1f6a9710dc6279","entry":"build_model","repo":"BeierZhu/VRF","repo_kind":"official","path":"clip/model.py","file_url":"https://github.com/BeierZhu/VRF/blob/HEAD/clip/model.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":"4e1f6a9710dc6279"}},{"code_sha256_prefix":"3903d266387afea6","entry":"get_classnames","repo":"BeierZhu/VRF","repo_kind":"official","path":"src/datasets/imagenet_classnames.py","file_url":"https://github.com/BeierZhu/VRF/blob/HEAD/src/datasets/imagenet_classnames.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":"3903d266387afea6"}},{"code_sha256_prefix":"3b97c12751c0cf5b","entry":"get_features","repo":"BeierZhu/VRF","repo_kind":"official","path":"src/datasets/common.py","file_url":"https://github.com/BeierZhu/VRF/blob/HEAD/src/datasets/common.py","link_basis":"harvester_set","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":"3b97c12751c0cf5b"}},{"code_sha256_prefix":"238ff32fcbf410d6","entry":"get_features_helper","repo":"BeierZhu/VRF","repo_kind":"official","path":"src/datasets/common.py","file_url":"https://github.com/BeierZhu/VRF/blob/HEAD/src/datasets/common.py","link_basis":"harvester_set","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":"238ff32fcbf410d6"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}