Civitai XGuard Profanity v1 — merged BF16 checkpoint
This is a profanity-specialized L0/L1/L2 text classifier, fine-tuned from the
original Alibaba-AAIG/YuFeng-XGuard-Reason-8B revision
383dd1079ef2708ef9f57622243885506dd38987. The repository root is a standard
merged Transformers checkpoint; the language adapter is already applied.
Training completed three epochs / 2,250 optimizer updates. Step 2,250 was selected by validation macro F1. The exact policy, data splits, training code, selected adapter, optimizer and RNG checkpoint, logs, metrics and continuation helpers are retained. This public reproducibility package includes the training data and review evidence as requested by the repository owner.
Profanity policy and outputs
- L0: No swearing or vulgar profanity. Other kinds of objectionable content do not independently determine this language axis.
- L1: Mild-to-moderate swearing or coarse insults without strong obscenity.
- L2: Strong obscene profanity, including clear compounds, derivatives, abbreviations and obfuscations in context.
Highest severity present wins. Quoted, disapproved, friendly or humorous profanity still counts. Literal harmless meanings and names do not become profanity through substring resemblance. Unsettled policy cases were withheld from the confident training set; they were not silently converted to L0.
The exact annotation policy, LanguageAny policy, LanguageStrong policy, and input/decoding contract are included. Model inputs contain only the full raw text and one policy. Reviews, IDs, source labels and split metadata are never fed to the model. This is a semantic model, not a vocabulary overlay.
Load and score
Download a pinned revision with authorized Hugging Face access. Use Python3.12
and uv; environment.lock.txt records the exact training/evaluation stack.
uv venv --python 3.12 .venv
uv pip install --python .venv/bin/python torch==2.9.1 \
--index-url https://download.pytorch.org/whl/cu128
uv pip install --python .venv/bin/python -r requirements-training.txt
uv run --no-project --python .venv/bin/python python infer.py \
--model-dir . --input-jsonl inputs.jsonl --output predictions.jsonl
Each input line is an object such as {"id":"example","text":"complete raw text"}.
The scorer also accepts JSONL on stdin or a complete UTF-8 file via
--text-file. It returns language_level (0/1/2), label, both attribute scores,
and the frozen thresholds. Raw input text is not echoed.
The reference path is BF16/SDPA with the original chat template,
reason_first=false, and one first-continuation decision token. Scores are
full-vocabulary P(x, token87), rounded to four decimals and zero if x is absent
from the top20. Do not renormalize x/sec probabilities, attach the adapter again,
truncate the input, or replace the frozen policies. The validated context
budget is 4,095 input tokens plus one output token.
Merged thresholds: LanguageAny 0.8174; LanguageStrong 0.622. L2 wins when Strong reaches its threshold; otherwise Any reaching its threshold means L1; otherwise L0. Match weights, tokenizer, policies, thresholds and cache version downstream. See deployment.json and thresholds.json.
Validation and test results
References are confident AI-reviewed English-source texts, not human-moderator gold or production accuracy. Canonical splits are 24,000 training texts, 3,000 validation texts and 3,000 test texts. There are two independent Boolean decisions per text. The original source toxicity/offensiveness labels were not mapped directly to profanity levels.
| Evaluation | Macro F1 | Accuracy |
|---|---|---|
| Original base, validation-calibrated, held-out test | 71.79% | 87.67% |
| Selected unmerged adapter, held-out test | 99.00% | 99.40% |
| Merged model, profanity validation | 99.57% | 99.80% |
| Merged model, same-test packaging confirmation | 99.00% | 99.40% |
| Merged test class | Support | Precision | Recall | F1 |
|---|---|---|---|---|
| L0 | 2282 | 99.52% | 99.74% | 99.63% |
| L1 | 383 | 98.44% | 98.69% | 98.57% |
| L2 | 335 | 99.70% | 97.91% | 98.80% |
The BF16 merge changed 1 validation level decision at the original adapter thresholds. Validation-only recalibration restored the selected validation macro F1. The merged weights and thresholds were then frozen before repeating the test for packaging confirmation. That repeated test is not a new untouched holdout, and no model or threshold was changed from its errors. The archived unmerged adapter retains its original thresholds and results.
Mean absolute merge score difference on the 6,000 validation decisions was 0.00007432; the maximum was 0.1224. Merging is not claimed bit-identical to applying the adapter at runtime. Different serving backends, quantization or batch shapes need parity checks.
- Merge checks
- Merged validation metrics
- Merged test confirmation
- Original adapter/base held-out comparison and intervals
- Profanity data integrity
- Training smoke tests
Resume or continue training
See CONTINUE_TRAINING.md. The repository retains a
profanity-only data/policy archive and the exact completed run at
training-context/run/, including the 1.4GB optimizer/RNG state. The selected and
last adapter weights are identical. Do not attach the archived adapter to the
already-merged root; continuation uses the exact original Alibaba base.
restore_training.py verifies and reconstructs a workspace.
prepare_continuation.py prepares a separate stage with verified data/base,
retained AdamW moments/RNG state and an explicit new scheduler. Neither helper
starts training automatically. The parent run remains unchanged. The original
test has now been evaluated; future changes motivated by its errors require a
fresh untouched confirmation set.
The training recipe used BF16 base weights, FP32 rank64 adapters/optimizer, alpha128, dropout0.05, attention+MLP projections, effective batch64, LR8e-5 with 5% warmup/cosine decay, three maximum epochs, train-only class weights, and full-vocabulary first-continuation CE. See training_config.json. No truncation, cross-example packing, quantization or synthetic relabeling was used.
Integrity and attribution
BUNDLE_MANIFEST.json covers the root inference bundle. UPLOAD_MANIFEST.json
covers the full publication. Run verify_publication.py through uv after
download. UPLOAD_VERIFICATION.json records remote file-hash verification.
Optimizer state uses PyTorch serialization; load only the checksum-verified
checkpoint from a source you trust.
Upstream: Alibaba AAIG and the YuFeng-XGuard contributors. See UPSTREAM_MODEL_CARD.md, LICENSE, and NOTICE. Original source licenses and provenance are retained with the profanity dataset archive; those source terms remain applicable to the data.