{"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/arxiv-2510-22851","title":"Semantic Surgery: Zero-Shot Concept Erasure in Diffusion Models","arxiv_id":"2510.22851","date":"2025-10-26","proceeding":"NeurIPS","authors":["Lexiang Xiong","Chengyu Liu","Jingwen Ye","Yan Liu","Yuecong Xu"],"abstract":"Concept erasure in text-to-image diffusion models is crucial for mitigating harmful content, yet existing methods often compromise generative quality. We introduce Semantic Surgery, a novel training-free, zero-shot framework for concept erasure that operates directly on text embeddings before the diffusion process. It dynamically estimates the presence of target concepts in a prompt and performs a calibrated vector subtraction to neutralize their influence at the source, enhancing both erasure completeness and locality. The framework includes a Co-Occurrence Encoding module for robust multi-concept erasure and a visual feedback loop to address latent concept persistence. As a training-free method, Semantic Surgery adapts dynamically to each prompt, ensuring precise interventions. Extensive experiments on object, explicit content, artistic style, and multi-celebrity erasure tasks show our method significantly outperforms state-of-the-art approaches. We achieve superior completeness and robustness while preserving locality and image quality (e.g., 93.58 H-score in object erasure, reducing explicit content to just 1 instance, and 8.09 H_a in style erasure with no quality degradation). This robustness also allows our framework to function as a built-in threat detection system, offering a practical solution for safer text-to-image generation.","url_abs":"https://arxiv.org/abs/2510.22851","url_pdf":"https://arxiv.org/pdf/2510.22851","source":{"archive":null,"snapshot":"2025-07-28","note":"not in the Papers with Code archive (frozen at the snapshot)","row_kind":"graph","title_abstract_authors_date":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)"},"code_links":[],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2510.22851","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2510.22851"}},"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":[{"mentioned_in_github":null,"is_official":null,"provenance":"deterministic:regex_extraction","mentioned_in_paper":null,"url":"https://github.com/Lexiang-Xiong/Semantic-Surgery","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":19},"by_repo_kind":{"found_in_text":{"samples":19,"ran":0,"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":"f4ead451d398bd73","entry":"cache_path","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"evaluation/eval_ASR.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/evaluation/eval_ASR.py","link_basis":"first_harvest_node","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":"f4ead451d398bd73"}},{"code_sha256_prefix":"31d9b92035c79e97","entry":"compute_similarity","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"src/utils.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/src/utils.py","link_basis":"first_harvest_node","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":"31d9b92035c79e97"}},{"code_sha256_prefix":"78f09e32d34ed9f9","entry":"concurrent_detection","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"evaluation/eval_aod.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/evaluation/eval_aod.py","link_basis":"first_harvest_node","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":"78f09e32d34ed9f9"}},{"code_sha256_prefix":"bbb4939397081666","entry":"detect_AOD","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"src/detection_aod.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/src/detection_aod.py","link_basis":"first_harvest_node","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":"bbb4939397081666"}},{"code_sha256_prefix":"d7478f40ee9494e2","entry":"draw_boxes_and_save","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"evaluation/eval_aod.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/evaluation/eval_aod.py","link_basis":"first_harvest_node","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":"d7478f40ee9494e2"}},{"code_sha256_prefix":"bd1f73e052a52c82","entry":"extract_celebrity_name","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"evaluation/eval_gcd.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/evaluation/eval_gcd.py","link_basis":"first_harvest_node","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":"bd1f73e052a52c82"}},{"code_sha256_prefix":"2a745b1635a32599","entry":"file_hash","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"evaluation/eval_ASR.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/evaluation/eval_ASR.py","link_basis":"first_harvest_node","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":"2a745b1635a32599"}},{"code_sha256_prefix":"14b4b6b059bebe6b","entry":"get_cache_file_path","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"evaluation/eval_nudity.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/evaluation/eval_nudity.py","link_basis":"first_harvest_node","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":"14b4b6b059bebe6b"}},{"code_sha256_prefix":"74bd6e7cc65d3067","entry":"get_concept_detected_with_owlvit","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"evaluation/eval_owl_vit.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/evaluation/eval_owl_vit.py","link_basis":"first_harvest_node","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":"74bd6e7cc65d3067"}},{"code_sha256_prefix":"4dd56ebd3bab6032","entry":"get_file_hash","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"evaluation/eval_nudity.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/evaluation/eval_nudity.py","link_basis":"first_harvest_node","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":"4dd56ebd3bab6032"}},{"code_sha256_prefix":"7d98b0ac8d4019eb","entry":"get_selected_alpha","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"src/utils.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/src/utils.py","link_basis":"first_harvest_node","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":"7d98b0ac8d4019eb"}},{"code_sha256_prefix":"18ef7add7df1433c","entry":"image_to_bytes","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"src/detection_aod.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/src/detection_aod.py","link_basis":"first_harvest_node","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":"18ef7add7df1433c"}},{"code_sha256_prefix":"f934c875a6a07f36","entry":"load_cache","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"evaluation/eval_ASR.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/evaluation/eval_ASR.py","link_basis":"first_harvest_node","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":"f934c875a6a07f36"}},{"code_sha256_prefix":"333c2209ff5831ac","entry":"load_cache","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"evaluation/eval_nudity.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/evaluation/eval_nudity.py","link_basis":"first_harvest_node","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":"333c2209ff5831ac"}},{"code_sha256_prefix":"5062c88d8f92da72","entry":"load_detector","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"src/Inference_cli.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/src/Inference_cli.py","link_basis":"first_harvest_node","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":"5062c88d8f92da72"}},{"code_sha256_prefix":"24270e828641d37e","entry":"parse_specify","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"src/SS_inference.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/src/SS_inference.py","link_basis":"first_harvest_node","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":"24270e828641d37e"}},{"code_sha256_prefix":"3043f283bc83b29d","entry":"read_checkpoint","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"src/SS_inference.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/src/SS_inference.py","link_basis":"first_harvest_node","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":"3043f283bc83b29d"}},{"code_sha256_prefix":"0e5bae723bce679d","entry":"safe_single_detection","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"evaluation/eval_aod.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/evaluation/eval_aod.py","link_basis":"first_harvest_node","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":"0e5bae723bce679d"}},{"code_sha256_prefix":"e3273240409a3942","entry":"sigmoid_kernel","repo":"Lexiang-Xiong/Semantic-Surgery","repo_kind":"found_in_text","path":"src/utils.py","file_url":"https://github.com/Lexiang-Xiong/Semantic-Surgery/blob/HEAD/src/utils.py","link_basis":"first_harvest_node","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":"e3273240409a3942"}}]},"arxiv_metadata":{"licence":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)","fields":["title","abstract","authors","date"],"primary_category":"cs.CV","source":"arxiv_api"},"syntology_extracted_results":null}