{"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/erasing-undesirable-concepts-in-diffusion","title":"Erasing Undesirable Concepts in Diffusion Models with Adversarial Preservation","arxiv_id":"2410.15618","date":"2024-10-21","proceeding":null,"authors":["Anh Bui","Long Vuong","Khanh Doan","Trung Le","Paul Montague","Tamas Abraham","Dinh Phung"],"abstract":"Diffusion models excel at generating visually striking content from text but can inadvertently produce undesirable or harmful content when trained on unfiltered internet data. A practical solution is to selectively removing target concepts from the model, but this may impact the remaining concepts. Prior approaches have tried to balance this by introducing a loss term to preserve neutral content or a regularization term to minimize changes in the model parameters, yet resolving this trade-off remains challenging. In this work, we propose to identify and preserving concepts most affected by parameter changes, termed as \\textit{adversarial concepts}. This approach ensures stable erasure with minimal impact on the other concepts. We demonstrate the effectiveness of our method using the Stable Diffusion model, showing that it outperforms state-of-the-art erasure methods in eliminating unwanted content while maintaining the integrity of other unrelated elements. Our code is available at \\url{https://github.com/tuananhbui89/Erasing-Adversarial-Preservation}.","url_abs":"https://arxiv.org/abs/2410.15618v3","url_pdf":"https://arxiv.org/pdf/2410.15618v3.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":"erasing-undesirable-concepts-in-diffusion","repo_url":"https://github.com/tuananhbui89/erasing-adversarial-preservation","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"erasing-undesirable-concepts-in-diffusion","repo_url":"https://github.com/tuananhbui89/adaptive-guided-erasure","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2410.15618","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.15618"}},"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/tuananhbui89/Erasing-Adversarial-Preservation","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/tuananhbui89/adaptive-guided-erasure","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/tuananhbui89/erasing-adversarial-preservation","reach":{"status":"ok"}}],"summary":{"ran_draft_wrong":2,"ran_violates":1,"ran_fixture":1,"unverified":7},"by_repo_kind":{"official":{"samples":11,"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":11,"samples":[{"code_sha256_prefix":"8241c0562bc710fd","entry":"chunk","repo":"tuananhbui89/Erasing-Adversarial-Preservation","repo_kind":"official","path":"generate_images_ldm.py","file_url":"https://github.com/tuananhbui89/Erasing-Adversarial-Preservation/blob/HEAD/generate_images_ldm.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8241c0562bc710fd"}},{"code_sha256_prefix":"1090950b58e9358b","entry":"gram_matrix","repo":"tuananhbui89/Erasing-Adversarial-Preservation","repo_kind":"official","path":"eval-scripts/styleloss.py","file_url":"https://github.com/tuananhbui89/Erasing-Adversarial-Preservation/blob/HEAD/eval-scripts/styleloss.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1090950b58e9358b"}},{"code_sha256_prefix":"1e63d588563eb90a","entry":"numpy_to_pil","repo":"tuananhbui89/Erasing-Adversarial-Preservation","repo_kind":"official","path":"generate_images_ldm.py","file_url":"https://github.com/tuananhbui89/Erasing-Adversarial-Preservation/blob/HEAD/generate_images_ldm.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1e63d588563eb90a"}},{"code_sha256_prefix":"15e005b12a64650d","entry":"sample_model","repo":"tuananhbui89/erasing-adversarial-preservation","repo_kind":"official","path":"train_adversarial_gumbel.py","file_url":"https://github.com/tuananhbui89/erasing-adversarial-preservation/blob/HEAD/train_adversarial_gumbel.py","link_basis":"first_harvest_node","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":"15e005b12a64650d"}},{"code_sha256_prefix":"0be5dca592f6fd54","entry":"get_vocab","repo":"tuananhbui89/Erasing-Adversarial-Preservation","repo_kind":"official","path":"gen_embedding_matrix.py","file_url":"https://github.com/tuananhbui89/Erasing-Adversarial-Preservation/blob/HEAD/gen_embedding_matrix.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":"0be5dca592f6fd54"}},{"code_sha256_prefix":"9ad49e53202d0110","entry":"image_loader","repo":"tuananhbui89/Erasing-Adversarial-Preservation","repo_kind":"official","path":"eval-scripts/styleloss.py","file_url":"https://github.com/tuananhbui89/Erasing-Adversarial-Preservation/blob/HEAD/eval-scripts/styleloss.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":"9ad49e53202d0110"}},{"code_sha256_prefix":"33b9cc6eebe44312","entry":"load_img","repo":"tuananhbui89/Erasing-Adversarial-Preservation","repo_kind":"official","path":"train_adversarial_pgd.py","file_url":"https://github.com/tuananhbui89/Erasing-Adversarial-Preservation/blob/HEAD/train_adversarial_pgd.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":"33b9cc6eebe44312"}},{"code_sha256_prefix":"dfb052a0af48540f","entry":"renew_resnet_paths","repo":"tuananhbui89/Erasing-Adversarial-Preservation","repo_kind":"official","path":"convertModels.py","file_url":"https://github.com/tuananhbui89/Erasing-Adversarial-Preservation/blob/HEAD/convertModels.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":"dfb052a0af48540f"}},{"code_sha256_prefix":"c5ec9c13e456a046","entry":"renew_vae_resnet_paths","repo":"tuananhbui89/Erasing-Adversarial-Preservation","repo_kind":"official","path":"convertModels.py","file_url":"https://github.com/tuananhbui89/Erasing-Adversarial-Preservation/blob/HEAD/convertModels.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":"c5ec9c13e456a046"}},{"code_sha256_prefix":"53b69f32ea5b7643","entry":"retrieve_embedding_token","repo":"tuananhbui89/Erasing-Adversarial-Preservation","repo_kind":"official","path":"gen_embedding_matrix.py","file_url":"https://github.com/tuananhbui89/Erasing-Adversarial-Preservation/blob/HEAD/gen_embedding_matrix.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":"53b69f32ea5b7643"}},{"code_sha256_prefix":"cea0bc82e0c96896","entry":"shave_segments","repo":"tuananhbui89/Erasing-Adversarial-Preservation","repo_kind":"official","path":"convertModels.py","file_url":"https://github.com/tuananhbui89/Erasing-Adversarial-Preservation/blob/HEAD/convertModels.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":"cea0bc82e0c96896"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}