{"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-patching-closing-the-subgroup","title":"Model Patching: Closing the Subgroup Performance Gap with Data Augmentation","arxiv_id":"2008.06775","date":"2020-08-15","proceeding":"ICLR 2021 1","authors":["Karan Goel","Albert Gu","Yixuan Li","Christopher Ré"],"abstract":"Classifiers in machine learning are often brittle when deployed. Particularly concerning are models with inconsistent performance on specific subgroups of a class, e.g., exhibiting disparities in skin cancer classification in the presence or absence of a spurious bandage. To mitigate these performance differences, we introduce model patching, a two-stage framework for improving robustness that encourages the model to be invariant to subgroup differences, and focus on class information shared by subgroups. Model patching first models subgroup features within a class and learns semantic transformations between them, and then trains a classifier with data augmentations that deliberately manipulate subgroup features. We instantiate model patching with CAMEL, which (1) uses a CycleGAN to learn the intra-class, inter-subgroup augmentations, and (2) balances subgroup performance using a theoretically-motivated subgroup consistency regularizer, accompanied by a new robust objective. We demonstrate CAMEL's effectiveness on 3 benchmark datasets, with reductions in robust error of up to 33% relative to the best baseline. Lastly, CAMEL successfully patches a model that fails due to spurious features on a real-world skin cancer dataset.","url_abs":"https://arxiv.org/abs/2008.06775v1","url_pdf":"https://arxiv.org/pdf/2008.06775v1.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-patching-closing-the-subgroup","repo_url":"https://github.com/HazyResearch/model-patching","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"tf","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"cancer-classification","task_name":"Cancer Classification"},{"task_slug":"data-augmentation","task_name":"Data Augmentation"},{"task_slug":"skin-cancer-classification","task_name":"Skin Cancer Classification"}],"methods":[{"method_slug":"batch-normalization","method_name":"Batch Normalization"},{"method_slug":"convolution","method_name":"Convolution"},{"method_slug":"cycle-consistency-loss","method_name":"Cycle Consistency Loss"},{"method_slug":"gan-least-squares-loss","method_name":"GAN Least Squares Loss"},{"method_slug":"instance-normalization","method_name":"Instance Normalization"},{"method_slug":"patchgan","method_name":"PatchGAN"},{"method_slug":"relu","method_name":"ReLU"},{"method_slug":"residual-block","method_name":"Residual Block"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"sigmoid-activation","method_name":"Sigmoid Activation"},{"method_slug":"tanh-activation","method_name":"Tanh Activation"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2008.06775","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2008.06775"}},"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/HazyResearch/model-patching","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran_fixture":1,"unverified":23},"by_repo_kind":{"official":{"samples":24,"ran":1,"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":"c4bb2cc4f4fe1b02","entry":"resnet_layer","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/models/resnet.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/models/resnet.py","link_basis":"plan_row","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c4bb2cc4f4fe1b02"}},{"code_sha256_prefix":"98c19e8ea2a7308a","entry":"apply_modifier_to_dataset","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/datasets/utils.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/datasets/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"98c19e8ea2a7308a"}},{"code_sha256_prefix":"ec4bd27e017d99d6","entry":"build_gan_loss_fn","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/methods/cyclegan/utils.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/methods/cyclegan/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ec4bd27e017d99d6"}},{"code_sha256_prefix":"2a61e37e02826736","entry":"compose_augmentations","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/augment/utils.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/augment/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"2a61e37e02826736"}},{"code_sha256_prefix":"030f94ea5ad5bd25","entry":"consistency_penalty","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/methods/robust/utils.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/methods/robust/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"030f94ea5ad5bd25"}},{"code_sha256_prefix":"fbb0bdc2392bddaf","entry":"create_augmentation_pipeline","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/augment/utils.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/augment/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"fbb0bdc2392bddaf"}},{"code_sha256_prefix":"333a830b360f3ea9","entry":"create_augmentation_pipelines","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/augment/utils.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/augment/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"333a830b360f3ea9"}},{"code_sha256_prefix":"20601a513934db43","entry":"create_cutout_mask","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/autoaugment/augmentation_transforms.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/autoaugment/augmentation_transforms.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"20601a513934db43"}},{"code_sha256_prefix":"e63a91f1aab1dcda","entry":"create_loss_fn","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/utilities/losses.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/utilities/losses.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e63a91f1aab1dcda"}},{"code_sha256_prefix":"b2de24ddcad94133","entry":"create_static_augmentation_pipeline","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/augment/static.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/augment/static.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b2de24ddcad94133"}},{"code_sha256_prefix":"fd8ccd0936eb0e95","entry":"dataflow_len","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/dataflows/utils.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/dataflows/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"fd8ccd0936eb0e95"}},{"code_sha256_prefix":"e0fde3fe1791c1c0","entry":"dataset_len","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/datasets/utils.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/datasets/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e0fde3fe1791c1c0"}},{"code_sha256_prefix":"fbc6e36eb3a7dc37","entry":"decay_weights","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/utilities/losses.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/utilities/losses.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"fbc6e36eb3a7dc37"}},{"code_sha256_prefix":"7331bb97aea96bf8","entry":"get_dataset_from_list_files_dataset","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/datasets/utils.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/datasets/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7331bb97aea96bf8"}},{"code_sha256_prefix":"1eb22022906e8429","entry":"gradient_penalty","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/methods/cyclegan/utils.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/methods/cyclegan/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"1eb22022906e8429"}},{"code_sha256_prefix":"6e1198a9c8c47438","entry":"random_flip","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/autoaugment/augmentation_transforms.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/autoaugment/augmentation_transforms.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"6e1198a9c8c47438"}},{"code_sha256_prefix":"9e1df2116f5f12de","entry":"resnet_v1","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/models/resnet.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/models/resnet.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"9e1df2116f5f12de"}},{"code_sha256_prefix":"10983517a862cfee","entry":"resnet_v2","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/models/resnet.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/models/resnet.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"10983517a862cfee"}},{"code_sha256_prefix":"04e4f19c8f00a35f","entry":"rewrite_config_for_resumption","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/methods/robust/utils.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/methods/robust/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"04e4f19c8f00a35f"}},{"code_sha256_prefix":"7730ae831bb01b7e","entry":"simple_cnn_model","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/models/models.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/models/models.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7730ae831bb01b7e"}},{"code_sha256_prefix":"34007c8abd15fb91","entry":"simple_model","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/models/models.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/models/models.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"34007c8abd15fb91"}},{"code_sha256_prefix":"26f24fe261bd5178","entry":"split_batch_size","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/augment/static.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/augment/static.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"26f24fe261bd5178"}},{"code_sha256_prefix":"6314c87eb9f70b97","entry":"wgan_loss","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/methods/cyclegan/utils.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/methods/cyclegan/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"6314c87eb9f70b97"}},{"code_sha256_prefix":"c5c143c5b39b3c1a","entry":"zero_pad_and_crop","repo":"HazyResearch/model-patching","repo_kind":"official","path":"augmentation/autoaugment/augmentation_transforms.py","file_url":"https://github.com/HazyResearch/model-patching/blob/HEAD/augmentation/autoaugment/augmentation_transforms.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c5c143c5b39b3c1a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}