Instructions to use yjernite/ncii-edit-guard-270m-v3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yjernite/ncii-edit-guard-270m-v3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="yjernite/ncii-edit-guard-270m-v3")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("yjernite/ncii-edit-guard-270m-v3") model = AutoModelForSequenceClassification.from_pretrained("yjernite/ncii-edit-guard-270m-v3", device_map="auto") - Notebooks
- Google Colab
- Kaggle
ncii-edit-guard-270m-v3
Third iteration of the lightweight prompt guard for image- and video-editing applications: a 3-class classifier scoring whether an editing prompt is likely a nudification / non-consensual intimate imagery (NCII) request about a person in the input. 268.1M parameters, ~4.2 ms/sequence (batch 8, A10G, CUDA). Supersedes v2; a 4-class experimental variant lives at v3-4class.
What changed in v3:
- Real NCII data: 357 train + 64 eval rows of real public NCII requests (TfGBV-Grok, CC-BY-NC-4.0, sanitized; meta-discussion and minor-mentioning rows excluded).
- Taxonomy-conditioned generation (Qwen3-30B-A3B-Instruct-2507, chosen over Qwen3-8B in a refusal/diversity pilot): clothing-replacement and JSON-spec families (the dominant real-world pattern, previously nearly absent), benign-phrasing ncii, explicit-situation, video-I2V, deictic-subject prompts, with contrastive minimal pairs (orientation/gender/ethnicity-flip safe edits), demographic-balanced safe rows, and religion/skin-tone safe cells β explicitly teaching the model not to over-moderate LGBTQIA and demographic categories.
- Asymmetric distillation retained from v2 (Shieldstral safe-side soft labels, Ξ±=0.3) + real-ncii rows Γ2 upweight.
- Style-disjoint synthetic eval slices so synthetic recall is not inflated by seed reuse; refusal-contaminated generations filtered.
Labels
safe(0) β edits that would not typically produce NCII on a user's photo/videoexplicit-not-person-targeted(1) β sexual/nudity content without an identifiable person as targetncii-risk(2) β nudification or sexualization of a person in the input (risk signal; consent is unknowable from text). Sublabels (nudify/explicit-situation/sexualize-reveal) are published on the dataset for analysis; the head is deliberately 3-class (see the 4-class variant's card for why).
from transformers import pipeline
clf = pipeline("text-classification", model="yjernite/ncii-edit-guard-270m-v3")
clf('{"action": "replace_clothes", "attire": "black bikini bra", "face_preserved": true}')
# [{'label': 'ncii-risk', 'score': ...}]
Evaluation β including the deployed baseline
All models scored on the same 3,699-row leakage-controlled eval (ncii-guard-eval-v1, gated). The deployed testing-app guard hfmlsoc/ncii-light-guard-v01 is binary β compared on the binary-compatible subset (n=3,439; its curated-splits-test rows are its own test split).
| Metric | light-guard-v01 (deployed) | v2 | v3 |
|---|---|---|---|
| ncii recall (all) | 0.633 | 0.725 | 0.924 |
| real ncii recall (held-out: curated-splits-test n=70 / grok n=55) | 1.00β / 0.745 | 0.743 / β | 0.786 / 0.964 |
| new-style abuse recall (clothing-replacement/JSON: synthetic-v3 slice) | 0.31 | β | 0.93 |
| i2p/T2I-style ncii recall | 0.333 | 0.519 | 0.556 |
| FPR on safe | 0.074 | 0.042 | 0.043 |
| explicit-class F1 | β | 0.63 | 0.65 |
| macro F1 (3-class models) | β | 0.782 | 0.831 |
β its own in-distribution test split; excluding it, its real-row recall is 0.51.
Disaggregated performance (95% Wilson CIs in results.json; demographic columns are text-signal proxies β gender via gendered pronouns only, ethnicity via census name lists, LGBT via signifier regexes β not self-identification; gender slices use eval/results_gender_text.json)
| Slice | light-guard (FPR/recall) | v3 (FPR / recall) |
|---|---|---|
| Gendered-pronoun safe prompts (she/her) | FPR 0.047 | FPR 0.063 [0.043β0.092] |
| Gendered-pronoun safe prompts (he/him) | FPR 0.063 | FPR 0.051 [0.031β0.082] β recall parity 0.953 vs 0.921 |
| Ethnicity-proxy safe FPR (white/api/black/hispanic) | 0.030 / 0.198 / 0.078 / 0.077 | 0.035 / 0.070 / 0.039 / 0.212 (hispanic n=52, CI 0.12β0.34) |
| LGBT over-refusal (orientation / trans / identity-other) | 0.124 / 0.134 / 0.088 | 0.016 / 0.029 / 0.038 |
| Same-sex vs different-sex partner ncii recall | 0.72 / 0.74 | 0.93 / 0.95 β no gap |
| Video ncii recall | 0.570 | 0.950 |
These are the clean-retrain numbers (trained on the released data composition). The gender FPR gap of v1 (3.3Γ) is closed (recall parity 0.95 vs 0.92 on the pronoun signal); the api-ethnicity FPR spike of the deployed guard is absent; LGBT affection prompts are flagged at 1β3% (deployed guard: 9β13%). Two points moved on the clean run and are flagged honestly: a hispanic-proxy safe-FPR elevation (0.212, n=52, CIs overlapping the other groups' upper bounds) and a lower i2p/T2I-style recall (0.556).
Limitations
- Text only; consent is unknowable from text; scores are heuristics, not proof of intent or harm.
- Real-row ncii recall (~0.79 on splits-test, 0.81 on all real rows) means roughly 1 in 5 real nudification-style requests is still missed.
- Demographic slices are proxies; the religion/skin-tone cells use crude signifier regexes.
- Sublabels on eval rows were rule-annotated and are being replaced by judge annotations (see
eval/gate_check.jsonand the 4-class card for the strict/reveal boundary analysis). - The Grok source is shaped by that service's guardrails (bikini-heavy); content-type weighting was triangulated across sources, not copied.
- Not a legal or safety guarantee.
Data & training
Train: the 31,274-row training assembly of ncii-guard-train-v1 (29,230 train + 1,961 dev as of the released version; this run predates two later data repairs β the refusal-row filter and the grok split fix β see the Model provenance table). Training: 3 epochs, eff. batch 32, lr 2e-5, class weights [1.0, 1.8, 1.8], Ξ±=0.3 soft-CE on Shieldstral safe-side labels, real-ncii Γ2, max len 512. Generation seeds and scripts in ncii-guard-synth-v1. Eval set is gated (manual approval) β request access for research/deployment evaluation.
Citation
Base: microsoft/harrier-oss-v1-270m. Teacher: mistralai/Shieldstral-1.0-3B. Instruments: I2P (arXiv:2211.05105), XSTest (arXiv:2308.01263), SNEACI taxonomy (arXiv:2606.27234). Predecessors: hfmlsoc/ncii-light-guard-v01, v1, v2.
- Downloads last month
- 23
Model tree for yjernite/ncii-edit-guard-270m-v3
Base model
microsoft/harrier-oss-v1-270m