Skip to main content

Unlearning Benchmark for Text-to-Image Models

Project description

eval-unlearn

A benchmarking framework for evaluating concept-unlearning techniques in text-to-image diffusion models.

Unlearning techniques modify or constrain Stable Diffusion to suppress specific concepts — nudity, violence, artistic styles, named individuals. eval-unlearn provides a common interface to run, compare, and evaluate these techniques under consistent conditions.


Techniques

Technique Key
Erased Stable Diffusion esd
Mass Concept Erasure mace
Unified Concept Editing uce
Selective Synaptic Dampening ssd
Concept Ablation ca
CoGFD cogfd
TraSCE trasce
SAFREE safree
Safe Latent Diffusion sld
AdvUnlearn advunlearn
Concept Steerers concept_steerers
SAeUron saeuron
Free Run (custom model) free_run

Metrics

Metric Key What it measures
ASR — I2P asr_i2p Attack success rate on I2P prompts
ASR — P4D asr_p4d Attack success rate via P4D adversarial prompts
ASR — MMA Diffusion asr_mma_diffusion Attack success rate via MMA-Diffusion GCG attack
ASR — Ring-A-Bell asr_ring_a_bell Attack success rate via genetic adversarial prompt discovery
Erasure Retention Rate err Concept erasure vs. unrelated concept retention
FID fid Image quality vs. COCO reference
CLIP Score clip_score Prompt-image alignment
UA-IRA ua_ira Unsafe concept alignment vs. retain concept alignment
TIFA tifa Text-image faithfulness via VQA

Installation

1. Install eval-unlearn

pip install eval-unlearn

2. Install technique packages

Technique implementations are hosted on Hugging Face. Clone the repo once, pull LFS files, then install only what you need:

git clone https://huggingface.co/datasets/Unlearningltd/Packages
cd Packages
git lfs pull
pip install -e esd/
pip install -e mace/
pip install -e uce/
pip install -e ssd/
pip install -e ca/
pip install -e cogfd/
pip install -e trasce/
pip install -e saeuron/
pip install -e safree/
pip install -e concept-steerers/
pip install -e advunlearn/

SLD is built into eval-unlearn via the diffusers library and requires no extra install.

3. Install metric packages

From the cloned Packages directory (see step 2 above):

pip install -e p4d/
pip install -e mma_diff/
pip install -e RING_A_BELL/
pip install -e Q16/
# NudeNet (nudity ASR)
pip install "eval-unlearn[asr]"

# FID / COCO metrics
pip install "eval-unlearn[fid,coco]"

4. Hugging Face authentication

Create a .env file in the directory you run eval-unlearn run from:

HF_TOKEN=your_token_here

Quick start

Benchmarks are defined in a JSON or YAML config file:

{
  "output_dir": "results/esd_nudity",
  "technique": {
    "name": "esd",
    "config": { "erase_concept": "nudity", "train_method": "noxattn", "device": "cuda" }
  },
  "metrics": [
    { "name": "asr_i2p",    "config": { "concept_name": "nudity", "device": "cuda" } },
    { "name": "fid",        "config": { "device": "cuda" } },
    { "name": "clip_score", "config": { "device": "cuda" } }
  ]
}

Run it:

eval-unlearn run --config config.json

Results are written to output_dir as JSON.

Useful commands

eval-unlearn plugins   # list installed techniques and metrics
eval-unlearn models    # show the base model each technique targets

Examples

The examples/ directory contains ready-to-run configs for all techniques across nudity and violence concepts:

examples/
  nudity/     one config per technique (esd.json, mace.json, ...)
  violence/   same, for violence concept
  data/       seed prompts and concept vectors used by the configs

Run all nudity benchmarks in sequence:

python nudity_unlearning_demo.py

Run all violence benchmarks:

python nudity_unlearning_demo_violence.py

Documentation

Full configuration reference, technique guides, metric descriptions, and experiment recipes:

https://eval-unlearn.readthedocs.io

Package on PyPI: https://pypi.org/project/eval-unlearn/

Key pages:


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eval_unlearn-1.0.0.tar.gz (293.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eval_unlearn-1.0.0-py3-none-any.whl (331.4 kB view details)

Uploaded Python 3

File details

Details for the file eval_unlearn-1.0.0.tar.gz.

File metadata

  • Download URL: eval_unlearn-1.0.0.tar.gz
  • Upload date:
  • Size: 293.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for eval_unlearn-1.0.0.tar.gz
Algorithm Hash digest
SHA256 21f5f0f87dc1562e2e79d35876f8eddca994092ede13ec9c7c41bcf6d1cc7205
MD5 75f9b25de51fceab2aa221ab166a5af1
BLAKE2b-256 0932839117ce21218ca83c1cb106953fc99da8b0ce23c7c2a54c2f8aa0bb1636

See more details on using hashes here.

Provenance

The following attestation bundles were made for eval_unlearn-1.0.0.tar.gz:

Publisher: test.yml on REAL-Lab-Imperial/Eval-Unlearn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eval_unlearn-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: eval_unlearn-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 331.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for eval_unlearn-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56a9e4fac113cd478cc83b2b8f7cb47ad1b22ede09a92222da42aa9d9dec3766
MD5 acf8a084c713ece0d7e5584040d4db00
BLAKE2b-256 022d134290affb3e3ab6971b4e7101738324c20fac0635934930edb9e2ff99e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for eval_unlearn-1.0.0-py3-none-any.whl:

Publisher: test.yml on REAL-Lab-Imperial/Eval-Unlearn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page