A lightweight prompt guard for image- and video-editing applications: a 3-class classifier that scores whether an editing prompt is likely to be a nudification / non-consensual intimate imagery (NCII) request about a person in the input. Built for latency- and memory-constrained deployment: 268.1M parameters, ~4.2 ms per sequence (batch 8, A10G, CUDA).
microsoft/harrier-oss-v1-270m (gemma3-text encoder, MIT), fine-tuned as Gemma3TextForSequenceClassification with a 3-class head, class-weighted cross-entropy (weights 1.0/1.8/1.8), 3 epochs, effective batch 32, lr 2e-5, max length 512.safe (0) — edits that would not typically produce NCII on a user's photo/video (clothing, background, restoration, style, …)explicit-not-person-targeted (1) — sexual/nudity content requested without an identifiable person as target (e.g. adding an anonymous nude figure to a landscape)ncii-risk (2) — nudification or sexualization of a person in the input. Since consent cannot be read from text, this is a risk signal, not a determination of intent.ncii-risk; policy decides whether explicit-not-person-targeted is also blocked.from transformers import pipeline
clf = pipeline("text-classification", model="yjernite/ncii-edit-guard-270m-v1")
clf("remove her top and make it look realistic")
# [{'label': 'ncii-risk', 'score': ...}]
23,348 real + 2,849 synthetic rows (yjernite/ncii-guard-train-v1):
| Source | Role | Rows |
|---|---|---|
curated-splits (train rows of ncii-guard-splits-v3-2k) |
real edit prompts, 15,336 safe + 1,200 ncii | 16,536 |
sd-prompts (Gustavosta/Stable-Diffusion-Prompts) |
real generic T2I prompts (sexual-keyword filtered) as safe negatives | 3,355 |
synthetic (ncii-guard-synth-v1, Qwen2.5-7B-generated, clearly marked) |
1,700 ncii-risk + 499 explicit + 800 contrastive safe | 2,849 |
i2p (AIML-TUDA/i2p, MIT) |
real T2I prompts; sexual→explicit or ncii (person mention); label-2 ×4 and label-1 ×2 oversampled in train only | 1,671 |
gedit-bench (stepfun-ai/GEdit-Bench, MIT) |
real editing instructions as safe negatives | 1,018 |
Dev (model selection) = held-out real rows + the val rows of ncii-guard-splits-v3-2k + 150 synthetic rows, so selection sees all three ncii distributions.
Eval set: yjernite/ncii-guard-eval-v1 — 3,078 rows, leakage-controlled (no train/dev prompt appears in eval; the one synthetic row that overlapped was removed). Composition: curated-splits-test 969 (its own test split — in-distribution for the binary baseline, never seen by this model), synthetic 949, sd-prompts 601, xstest 250, gedit-bench 171, i2p 138. Full per-row predictions: eval/predictions.parquet.
Overall: accuracy 0.892 · macro F1 0.804 · weighted F1 0.893 · per-class F1: safe 0.938 / explicit 0.619 / ncii 0.856 · recall on ncii-risk 0.895 · FPR on safe 0.077.
Demographic attributes are proxies inferred from names in the prompt (census-based ethnicity groups; gender-guesser for gender; relationship terms for orientation) — they are not self-identification and slices mix real and synthetic rows.
NCII-risk recall by gender proxy (named slices): female 0.928 [0.893–0.952] · male 0.914 [0.877–0.940] — no significant recall gap. FPR on safe by gender proxy: female 0.170 [0.110–0.253] vs male 0.051 [0.026–0.097] — a significant ~3× over-flagging of prompts that name women. This is the headline disparate-performance finding and a known harm-amplification risk (real NCII targets skew female; see arXiv 2606.27234).
NCII-risk recall by ethnicity proxy: white 0.888 [0.831–0.927] · api 0.922 [0.869–0.955] · black 0.928 [0.875–0.959] · hispanic 0.934 [0.882–0.964] — CIs overlap. FPR on safe by ethnicity proxy: white 0.040 [0.020–0.077] · api 0.074 [0.048–0.115] · black 0.098 [0.043–0.210] · hispanic 0.173 [0.094–0.297] — a rising trend, highest for the hispanic-proxy slice (borderline significant vs white).
By orientation proxy: recall partner-female 0.954 vs partner-male 0.946 (CIs overlap, no gap); FPR 0.0 on both (very small n: 10 and 6 safe rows).
By source (recall on ncii-risk): synthetic 0.938 · real (curated-splits-test) 0.743 [0.630–0.831] · i2p-style T2I prompts 0.333 [0.186–0.522] — a real domain gap on T2I tag-soup-style prompts.
By media: image 0.940 · video 0.930 (synthetic slices); safe-side FPR ~0.09–0.10 on both.
Over-refusal: XSTest safe prompts FPR 0.156 [0.116–0.206]; generic sd-prompts FPR 0.108 [0.086–0.136]; real edit instructions (gedit) 0.012.
hfmlsoc/ncii-light-guard-v01 (binary, same base model, trained on the same split family) on the binary-comparable subset of this eval: recall on ncii-risk 0.729 overall / 0.814 on real rows, FPR 0.074. On the real-ncii slice it is stronger than this model (its test split is in-distribution for it) — see baseline_lightguard_results.json. This model's added value: the explicit-not-person-targeted class (F1 0.619), the demographic disaggregation, and better synthetic-slice recall.
268.1M parameters. Measured: 4.2 ms/sequence (batch 8, A10G, CUDA, bf16). CPU (fp32) measured 3.9 s/sequence on the eval job's 4-vCPU container — treat as an unoptimized upper bound and measure on your target hardware; the model runs comfortably on CPU-class hardware with a tuned runtime.
source=synthetic; real-world recall is best estimated from the real rows (0.743 on held-out real ncii prompts).safe score is not a guarantee, and an ncii-risk score is not proof of intent.Training/eval code and seeds: generation seeds in ncii-guard-synth-v1/seeds_used.json; build scripts kept with the datasets. Sources: i2p (MIT), GEdit-Bench (MIT), XSTest (CC-BY-4.0), Gustavosta prompts, ncii-guard-splits-v3-2k (author-provided). Non-redistributable sources (CC-BY-NC-ND MMA-Diffusion) were deliberately excluded from the shipped set.
Base model: microsoft/harrier-oss-v1-270m. Evaluation instruments: I2P (arXiv:2211.05105), XSTest (arXiv:2308.01263). Baseline model and split family: hfmlsoc/ncii-light-guard-v01.
Status: deprecated — v3 outperforms this model on every automated metric measured (overall and disaggregated). Kept public as the baseline for the published results; prefer v3 (or the 4-class variant) for deployment.
A third iteration is now available: yjernite/ncii-edit-guard-270m-v3, trained with real NCII requests (TfGBV-Grok), taxonomy-conditioned generation (clothing-replacement/JSON-spec families), and contrastive demographic examples. On the current 3,699-row eval (this model scored on the same set): v2 ncii recall 0.725 → v3 0.923; real held-out recall 0.743 → 0.786 (splits-test) and 0.909 (grok); FPR on safe 0.042 → 0.038; macro F1 0.782 → 0.841; female-vs-male FPR gap further narrowed; LGBT over-refusal FPR 0.016–0.038 → 0.000–0.031. The deployed binary baseline hfmlsoc/ncii-light-guard-v01 scores 0.633 recall / 0.074 FPR on the same set and fails on the clothing-replacement/JSON abuse style (recall 0.31). Full disaggregated tables: v3 model card and each repo's eval/results.json.
model.safetensors 536 MBtraining_args.bin 5.2 kBmicrosoft/harrier-oss-v1-270m