{"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/model-soups-averaging-weights-of-multiple","title":"Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time","arxiv_id":"2203.05482","date":"2022-03-10","proceeding":null,"authors":["Mitchell Wortsman","Gabriel Ilharco","Samir Yitzhak Gadre","Rebecca Roelofs","Raphael Gontijo-Lopes","Ari S. Morcos","Hongseok Namkoong","Ali Farhadi","Yair Carmon","Simon Kornblith","Ludwig Schmidt"],"abstract":"The conventional recipe for maximizing model accuracy is to (1) train multiple models with various hyperparameters and (2) pick the individual model which performs best on a held-out validation set, discarding the remainder. In this paper, we revisit the second step of this procedure in the context of fine-tuning large pre-trained models, where fine-tuned models often appear to lie in a single low error basin. We show that averaging the weights of multiple models fine-tuned with different hyperparameter configurations often improves accuracy and robustness. Unlike a conventional ensemble, we may average many models without incurring any additional inference or memory costs -- we call the results \"model soups.\" When fine-tuning large pre-trained models such as CLIP, ALIGN, and a ViT-G pre-trained on JFT, our soup recipe provides significant improvements over the best model in a hyperparameter sweep on ImageNet. The resulting ViT-G model, which attains 90.94% top-1 accuracy on ImageNet, achieved a new state of the art. Furthermore, we show that the model soup approach extends to multiple image classification and natural language processing tasks, improves out-of-distribution performance, and improves zero-shot performance on new downstream tasks. Finally, we analytically relate the performance similarity of weight-averaging and logit-ensembling to flatness of the loss and confidence of the predictions, and validate this relation empirically. Code is available at https://github.com/mlfoundations/model-soups.","url_abs":"https://arxiv.org/abs/2203.05482v3","url_pdf":"https://arxiv.org/pdf/2203.05482v3.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":"model-soups-averaging-weights-of-multiple","repo_url":"https://github.com/mlfoundations/model-soups","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"model-soups-averaging-weights-of-multiple","repo_url":"https://github.com/Burf/ModelSoups","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":null},{"paper_slug":"model-soups-averaging-weights-of-multiple","repo_url":"https://github.com/facebookresearch/ModelRatatouille","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"model-soups-averaging-weights-of-multiple","repo_url":"https://github.com/flowritecom/flow-merge","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"model-soups-averaging-weights-of-multiple","repo_url":"https://github.com/shallowlearn/sportsreid","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"model-soups-averaging-weights-of-multiple","repo_url":"https://github.com/hwk0702/keras2torch/tree/main/Computer_Vision/Model_Soup","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"domain-generalization","task_name":"Domain Generalization"},{"task_slug":"image-classification","task_name":"Image Classification"},{"task_slug":"out-of-distribution-generalization","task_name":"Out-of-Distribution Generalization"},{"task_slug":"unsupervised-domain-adaptation","task_name":"Unsupervised Domain Adaptation"},{"task_slug":"image-classification","task_name":"image-classification"}],"methods":[{"method_slug":"align","method_name":"ALIGN"},{"method_slug":"clip","method_name":"CLIP"},{"method_slug":"soups","method_name":"Soups"}],"datasets_introduced":[],"methods_introduced":[{"slug":"soups","name":"Soups","full_name":"Model Soups"}],"results":[{"leaderboard":"/sota/on-1","task":"","dataset":"","model":"","rank_in_archive_order":5,"of":6,"metrics":{},"uses_additional_data":false},{"leaderboard":"/sota/domain-generalization-on-imagenet-a","task":"Domain Generalization","dataset":"ImageNet-A","model":"Model soups (BASIC-L)","rank_in_archive_order":1,"of":39,"metrics":{"Top-1 accuracy %":"94.17"},"uses_additional_data":true},{"leaderboard":"/sota/domain-generalization-on-imagenet-a","task":"Domain Generalization","dataset":"ImageNet-A","model":"Model soups (ViT-G/14)","rank_in_archive_order":2,"of":39,"metrics":{"Top-1 accuracy %":"92.67"},"uses_additional_data":true},{"leaderboard":"/sota/domain-generalization-on-imagenet-r","task":"Domain Generalization","dataset":"ImageNet-R","model":"Model soups (BASIC-L)","rank_in_archive_order":1,"of":39,"metrics":{"Top-1 Error Rate":"3.90"},"uses_additional_data":true},{"leaderboard":"/sota/domain-generalization-on-imagenet-r","task":"Domain Generalization","dataset":"ImageNet-R","model":"Model soups (ViT-G/14)","rank_in_archive_order":2,"of":39,"metrics":{"Top-1 Error Rate":"4.54"},"uses_additional_data":true},{"leaderboard":"/sota/domain-generalization-on-imagenet-sketch","task":"Domain Generalization","dataset":"ImageNet-Sketch","model":"Model soups (BASIC-L)","rank_in_archive_order":1,"of":20,"metrics":{"Top-1 accuracy":"77.18"},"uses_additional_data":true},{"leaderboard":"/sota/domain-generalization-on-imagenet-sketch","task":"Domain Generalization","dataset":"ImageNet-Sketch","model":"Model soups (ViT-G/14)","rank_in_archive_order":2,"of":20,"metrics":{"Top-1 accuracy":"74.24"},"uses_additional_data":true},{"leaderboard":"/sota/image-classification-on-imagenet","task":"Image Classification","dataset":"ImageNet","model":"Model soups (BASIC-L)","rank_in_archive_order":2,"of":1060,"metrics":{"Number of params":"2440M","Top 1 Accuracy":"90.98%"},"uses_additional_data":false},{"leaderboard":"/sota/image-classification-on-imagenet","task":"Image Classification","dataset":"ImageNet","model":"Model soups (ViT-G/14)","rank_in_archive_order":3,"of":1060,"metrics":{"Number of params":"1843M","Top 1 Accuracy":"90.94%"},"uses_additional_data":false},{"leaderboard":"/sota/image-classification-on-imagenet-real","task":"Image Classification","dataset":"ImageNet ReaL","model":"Baseline (ViT-G/14)","rank_in_archive_order":1,"of":57,"metrics":{"Accuracy":"91.78%"},"uses_additional_data":true},{"leaderboard":"/sota/image-classification-on-imagenet-real","task":"Image Classification","dataset":"ImageNet ReaL","model":"Model soups (ViT-G/14)","rank_in_archive_order":3,"of":57,"metrics":{"Accuracy":"91.20%","Params":"1843M"},"uses_additional_data":true},{"leaderboard":"/sota/image-classification-on-imagenet-real","task":"Image Classification","dataset":"ImageNet ReaL","model":"Model soups (BASIC-L)","rank_in_archive_order":7,"of":57,"metrics":{"Accuracy":"91.03%","Params":"2440M"},"uses_additional_data":true},{"leaderboard":"/sota/image-classification-on-imagenet-v2","task":"Image Classification","dataset":"ImageNet V2","model":"Model soups (BASIC-L)","rank_in_archive_order":1,"of":33,"metrics":{"Top 1 Accuracy":"84.63"},"uses_additional_data":true},{"leaderboard":"/sota/image-classification-on-imagenet-v2","task":"Image Classification","dataset":"ImageNet V2","model":"Model soups (ViT-G/14)","rank_in_archive_order":3,"of":33,"metrics":{"Top 1 Accuracy":"84.22"},"uses_additional_data":true},{"leaderboard":"/sota/image-classification-on-objectnet","task":"Image Classification","dataset":"ObjectNet","model":"Baseline (ViT-G/14)","rank_in_archive_order":5,"of":106,"metrics":{"Top-1 Accuracy":"79.03"},"uses_additional_data":true},{"leaderboard":"/sota/image-classification-on-objectnet","task":"Image Classification","dataset":"ObjectNet","model":"Model soups (ViT-G/14)","rank_in_archive_order":6,"of":106,"metrics":{"Top-1 Accuracy":"78.52"},"uses_additional_data":true},{"leaderboard":"/sota/unsupervised-domain-adaptation-on-imagenet-r","task":"Unsupervised Domain Adaptation","dataset":"ImageNet-R","model":"Model soups (ViT-G/14)","rank_in_archive_order":1,"of":8,"metrics":{"Top 1 Error":"4.54"},"uses_additional_data":true}],"syntology":{"syntology_url":"https://syntology.ai/paper/2203.05482","atlas_url":"https://app.syntology.ai/?focus=2203.05482","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2203.05482"}},"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/mlfoundations/model-soups","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/shallowlearn/sportsreid","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/hwk0702/keras2torch/tree/main/Computer_Vision/Model_Soup","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/Burf/ModelSoups","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/facebookresearch/ModelRatatouille","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/flowritecom/flow-merge","reach":null}],"summary":{"ran":3,"ran_fixture":2,"ran_draft_wrong":3,"unverified":9},"by_repo_kind":{"listed":{"samples":17,"ran":8,"repositories":3}},"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":"579350baa15e6159","entry":"deit_b_16","repo":"shallowlearn/sportsreid","repo_kind":"listed","path":"torchreid/models/deit.py","file_url":"https://github.com/shallowlearn/sportsreid/blob/HEAD/torchreid/models/deit.py","link_basis":"harvester_set","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":"579350baa15e6159"}},{"code_sha256_prefix":"21a17fccb849b495","entry":"deit_bd_16","repo":"shallowlearn/sportsreid","repo_kind":"listed","path":"torchreid/models/deit.py","file_url":"https://github.com/shallowlearn/sportsreid/blob/HEAD/torchreid/models/deit.py","link_basis":"harvester_set","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":"21a17fccb849b495"}},{"code_sha256_prefix":"77f2a9201dc21413","entry":"greedy_soup","repo":"Burf/ModelSoups","repo_kind":"listed","path":"model_soup/tf.py","file_url":"https://github.com/Burf/ModelSoups/blob/HEAD/model_soup/tf.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"77f2a9201dc21413"}},{"code_sha256_prefix":"a91938d0faee2d10","entry":"greedy_soup","repo":"Burf/ModelSoups","repo_kind":"listed","path":"model_soup/torch.py","file_url":"https://github.com/Burf/ModelSoups/blob/HEAD/model_soup/torch.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a91938d0faee2d10"}},{"code_sha256_prefix":"60c22e32adfbec53","entry":"make_args_lp","repo":"facebookresearch/ModelRatatouille","repo_kind":"listed","path":"domainbed/scripts/sweep.py","file_url":"https://github.com/facebookresearch/ModelRatatouille/blob/HEAD/domainbed/scripts/sweep.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"60c22e32adfbec53"}},{"code_sha256_prefix":"9635afee4069aa90","entry":"nasnetamobile","repo":"shallowlearn/sportsreid","repo_kind":"listed","path":"torchreid/models/nasnet.py","file_url":"https://github.com/shallowlearn/sportsreid/blob/HEAD/torchreid/models/nasnet.py","link_basis":"harvester_set","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":"9635afee4069aa90"}},{"code_sha256_prefix":"0dd770f57fbaf113","entry":"uniform_soup","repo":"Burf/ModelSoups","repo_kind":"listed","path":"model_soup/tf.py","file_url":"https://github.com/Burf/ModelSoups/blob/HEAD/model_soup/tf.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0dd770f57fbaf113"}},{"code_sha256_prefix":"abb74c81ad65b75e","entry":"uniform_soup","repo":"Burf/ModelSoups","repo_kind":"listed","path":"model_soup/torch.py","file_url":"https://github.com/Burf/ModelSoups/blob/HEAD/model_soup/torch.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"abb74c81ad65b75e"}},{"code_sha256_prefix":"f6f2c3de62b310dc","entry":"deit_bd_16_384","repo":"shallowlearn/sportsreid","repo_kind":"listed","path":"torchreid/models/deit.py","file_url":"https://github.com/shallowlearn/sportsreid/blob/HEAD/torchreid/models/deit.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":"f6f2c3de62b310dc"}},{"code_sha256_prefix":"8e96abe9674da973","entry":"densenet121","repo":"shallowlearn/sportsreid","repo_kind":"listed","path":"torchreid/models/densenet.py","file_url":"https://github.com/shallowlearn/sportsreid/blob/HEAD/torchreid/models/densenet.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":"8e96abe9674da973"}},{"code_sha256_prefix":"54d10942ab6a6650","entry":"densenet169","repo":"shallowlearn/sportsreid","repo_kind":"listed","path":"torchreid/models/densenet.py","file_url":"https://github.com/shallowlearn/sportsreid/blob/HEAD/torchreid/models/densenet.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":"54d10942ab6a6650"}},{"code_sha256_prefix":"372747120f68c12f","entry":"densenet201","repo":"shallowlearn/sportsreid","repo_kind":"listed","path":"torchreid/models/densenet.py","file_url":"https://github.com/shallowlearn/sportsreid/blob/HEAD/torchreid/models/densenet.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":"372747120f68c12f"}},{"code_sha256_prefix":"968ff7bf292adbec","entry":"inceptionresnetv2","repo":"shallowlearn/sportsreid","repo_kind":"listed","path":"torchreid/models/inceptionresnetv2.py","file_url":"https://github.com/shallowlearn/sportsreid/blob/HEAD/torchreid/models/inceptionresnetv2.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":"968ff7bf292adbec"}},{"code_sha256_prefix":"2bcd3828691ac1d1","entry":"inceptionv4","repo":"shallowlearn/sportsreid","repo_kind":"listed","path":"torchreid/models/inceptionv4.py","file_url":"https://github.com/shallowlearn/sportsreid/blob/HEAD/torchreid/models/inceptionv4.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":"2bcd3828691ac1d1"}},{"code_sha256_prefix":"b52023dd659c7a90","entry":"mlfn","repo":"shallowlearn/sportsreid","repo_kind":"listed","path":"torchreid/models/mlfn.py","file_url":"https://github.com/shallowlearn/sportsreid/blob/HEAD/torchreid/models/mlfn.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":"b52023dd659c7a90"}},{"code_sha256_prefix":"85b4bac4b8d2c9e4","entry":"mobilenetv2_x1_0","repo":"shallowlearn/sportsreid","repo_kind":"listed","path":"torchreid/models/mobilenetv2.py","file_url":"https://github.com/shallowlearn/sportsreid/blob/HEAD/torchreid/models/mobilenetv2.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":"85b4bac4b8d2c9e4"}},{"code_sha256_prefix":"92bf5ac4db6e8f28","entry":"mobilenetv2_x1_4","repo":"shallowlearn/sportsreid","repo_kind":"listed","path":"torchreid/models/mobilenetv2.py","file_url":"https://github.com/shallowlearn/sportsreid/blob/HEAD/torchreid/models/mobilenetv2.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":"92bf5ac4db6e8f28"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}