Papers › EraseAnything: Enabling Concept Erasure in Rectified Flow Transformers

EraseAnything: Enabling Concept Erasure in Rectified Flow Transformers

29 Dec 2024arXiv:2412.20413archive 2025-07-28

Daiheng Gao, Shilin Lu, Shaw Walters, Wenbo Zhou, Jiaming Chu, Jie Zhang, Bang Zhang, Mengxi Jia, Jian Zhao, Zhaoxin Fan, Weiming Zhang

Removing unwanted concepts from large-scale text-to-image (T2I) diffusion models while maintaining their overall generative quality remains an open challenge. This difficulty is especially pronounced in emerging paradigms, such as Stable Diffusion (SD) v3 and Flux, which incorporate flow matching and transformer-based architectures. These advancements limit the transferability of existing concept-erasure techniques that were originally designed for the previous T2I paradigm (e.g., SD v1.4). In this work, we introduce EraseAnything, the first method specifically developed to address concept erasure within the latest flow-based T2I framework. We formulate concept erasure as a bi-level optimization problem, employing LoRA-based parameter tuning and an attention map regularizer to selectively suppress undesirable activations. Furthermore, we propose a self-contrastive learning strategy to ensure that removing unwanted concepts does not inadvertently harm performance on unrelated ones. Experimental results demonstrate that EraseAnything successfully fills the research gap left by earlier methods in this new T2I paradigm, achieving state-of-the-art performance across a wide range of concept erasure tasks.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2412.20413")

Code

Syntology Ran 0 of 16 code samples harvested from 1 repository linked to this paper; 16 have no recorded run.

By repository: official repository: 16 samples from 1 repository, 0 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

tomguluson92/eraseanything officialmentioned on GitHubjaxBSD-3-Clause report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

16 samples harvested; 0 ran; 0 honoured the contract we drafted; 16 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

16unverified

Licence: 0 of the 16 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from tomguluson92/eraseanything. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: 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. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

MoE tomguluson92/eraseanything/ir_concept.py official repository unverified BSD-3-Clause (permissive) · 2f410d45aa8c1315 · report
calculate_steer_loss tomguluson92/eraseanything/utils/infoNCE.py official repository unverified BSD-3-Clause (permissive) · 2ff43c37cdeed4e6 · report
collate_data_fn tomguluson92/eraseanything/lora_dataset.py official repository unverified BSD-3-Clause (permissive) · cf4b316a3a6d6746 · report
encode_prompt tomguluson92/eraseanything/prompt_process.py official repository unverified BSD-3-Clause (permissive) · 39f2be6188e09424 · report
filt_response tomguluson92/eraseanything/ir_concept.py official repository unverified BSD-3-Clause (permissive) · 0393606cc9b74f59 · report
flux_pack_latents tomguluson92/eraseanything/utils/esd_utils.py official repository unverified BSD-3-Clause (permissive) · 1f1b5d50699bbba0 · report
flux_unpack_latents tomguluson92/eraseanything/utils/esd_utils.py official repository unverified BSD-3-Clause (permissive) · d90a243dc7ac73ad · report
get_sigmas tomguluson92/eraseanything/utils/calc_loss.py official repository unverified BSD-3-Clause (permissive) · 9ed681562f12226e · report
get_synonyms tomguluson92/eraseanything/lora_dataset.py official repository unverified BSD-3-Clause (permissive) · c1a4a7602c9e7e4d · report
get_word_index tomguluson92/eraseanything/utils/find_token.py official repository unverified BSD-3-Clause (permissive) · 36355b45444139e9 · report
import_model_class_from_model_name_or_path tomguluson92/eraseanything/train_flux_lora.py official repository unverified BSD-3-Clause (permissive) · 212f670149d23d38 · report
latent_sample tomguluson92/eraseanything/utils/esd_utils.py official repository unverified BSD-3-Clause (permissive) · c140516be52da6c8 · report
load_text_encoders tomguluson92/eraseanything/train_flux_lora.py official repository unverified BSD-3-Clause (permissive) · d38b6b75175267f1 · report
search_sequence_numpy tomguluson92/eraseanything/utils/find_token.py official repository unverified BSD-3-Clause (permissive) · c45ebec24dc3adce · report
tidy_output tomguluson92/eraseanything/ir_concept.py official repository unverified BSD-3-Clause (permissive) · 2e5bb2364f868e35 · report
tokenize_prompt tomguluson92/eraseanything/prompt_process.py official repository unverified BSD-3-Clause (permissive) · 442d96197841458f · report

Tasks

Contrastive Learning

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AttentionDiffusionSoftmax

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections