Skip to main content
LECO (Low-rank adaptation for Erasing COncepts from diffusion models) trains a LoRA that modifies what a diffusion model generates — without any training images. All training signals come from the difference between the model’s own noise predictions on different text prompts.
LECO is well suited for safety and content filtering use cases. You can erase unwanted styles, subjects, or content from a model’s outputs without touching any training data or model weights directly. The resulting LoRA can be selectively applied or removed at inference time.

What LECO can do

Concept erasing

Remove a specific style or concept from generated images. Example: erase the “van gogh” painting style so the model stops producing Van Gogh-like outputs.

Concept enhancing

Strengthen a specific attribute. Example: make “detailed” more pronounced so the model consistently produces higher-detail outputs when prompted.

Slider LoRA

Create a bidirectional attribute slider. Example: a LoRA where positive weights produce “long hair” and negative weights produce “short hair”.

LECO vs standard LoRA

Scripts

Prompt TOML configuration

Instead of a dataset TOML, LECO uses a prompt TOML file that defines the concepts and directions to train. Two formats are supported.

Format 1: Original LECO format

Use [[prompts]] sections for direct control over each training pair:

Format 2: Slider target format (ai-toolkit style)

Use [[targets]] sections to define slider-style LoRAs. Each target automatically expands into bidirectional training pairs:
Top-level fields (guidance_scale, resolution, neutral, batch_size) serve as defaults for all targets. * At least one of positive or negative must be provided.

Multiple neutral prompts

You can specify multiple neutral prompts to improve generalization across different contexts:
You can also load neutrals from a text file (one prompt per line):

Three use case examples

Erase a specific artistic style from the model’s outputs by training against its own predictions of that style.
After training, applying this LoRA reduces the model’s tendency to produce Van Gogh-like brushwork and color palettes even when prompted.
Strengthen an attribute so the model more consistently applies it.
After training, applying this LoRA with a positive weight makes the model produce more detailed outputs.
Create a bidirectional slider between two attributes. Apply positive weights to go one direction, negative weights to go the other.
At inference, use weight 1.0 for long hair and weight -1.0 for short hair.

Key arguments

LECO has two separate guidance scale controls:
  1. --leco_denoise_guidance_scale (command-line): Controls CFG strength during the partial denoising pass that generates intermediate latents. Higher values produce more prompt-adherent latents for the training signal.
  2. guidance_scale (in the TOML file): Controls the magnitude of the concept offset when constructing the training target. Higher values produce a stronger erase/enhance effect. This can be set per-prompt or per-target.
If your results are too subtle, increase the TOML guidance_scale (try 1.5 to 3.0).

Training commands

Using the trained model

The trained LoRA .safetensors file is saved to --output_dir. Load it in AUTOMATIC1111, ComfyUI, or any Diffusers-based tool just like a standard LoRA. For slider LoRAs:
  • Apply a positive weight (e.g., 0.5 to 1.5) to move in the positive direction.
  • Apply a negative weight (e.g., -0.5 to -1.5) to move in the negative direction.

Tuning the effect strength

If the trained LoRA has a weak or unnoticeable effect:
  1. Increase guidance_scale in the TOML (e.g., from 1.0 to 2.0). This is the most direct adjustment.
  2. Increase multiplier in the TOML (e.g., from 1.0 to 2.0).
  3. Increase --max_denoising_steps for more refined intermediate latents.
  4. Increase --max_train_steps to train longer.
  5. Apply the LoRA with a higher weight at inference time.