CoolFace
Modelpublic

flowxai/moderation

sourceHugging Faceapache-2.0updated 28d agoView on Hugging Face
0likes107downloads
Model Card

moderation[border]

The moderation detector for border, an embeddable library that inspects the text going into and coming out of an LLM and returns a structured decision plus an audit-grade evidence record.

flowxai/moderation on the hub. It is one detector of 28, and it is not a general purpose moderation classifier: it was trained for this library's policy, is read at the operating point below, and reports through the evidence record rather than returning a bare score.

This card is generated from the evaluation and export artifacts of the training run, so every number on it is reproducible from this repository rather than asserted.

What it is

  • Base model: FacebookAI/xlm-roberta-base
  • Head: multilabelclassification
  • Labels: cyber_intrusion, defamation, election_integrity, extremism, fraud_deception, hate_incitement, illicit_drugs, property_crime, self_harm, sexual_exploitation, violent_facilitation, weapons_cbrn
  • Artifact: onnx/model.int8.onnx, 535 MB, opset 17
  • Trained at: 96 tokens

12 labels, and what is missing

The taxonomy this detector implements defines 13 labels. This head was trained on 12. The rest are listed here rather than omitted, because a card that names only what a model can do presents partial coverage as complete.

  • `child_safety`: must not be synthetically generated. The label covers sexualisation of minors and grooming, and no length band or framing makes generating either acceptable. It needs a vetted source with its provenance recorded, which is a decision about provenance rather than compute. Until then moderation is a twelve-label head and the thirteenth reports unavailable rather than clean.

In flowx-border a label with no training behind it is reported as unavailable rather than as clean. A detector that silently scores zero on something it cannot see is indistinguishable from one that looked and found nothing.

Operating point

Threshold 0.91, calibrated on the validation split against the macro_f1 objective.

This number is not decoration. Read at the 0.5 default that looked reasonable, several detectors in this family reported F1 0.000 in every language, because their scores separate positives from negatives well below 0.5. One of them went from 0.000 to 0.893 on the threshold alone. Use the value above, or calibrate your own on your own data.

This threshold is not a tuned parameter, and the shipped policy default stays at 0.84. Three runs against this corpus, two seed replicates and this retrain, read 0.69, 0.83 and 0.81, and the validation curve is flat across the whole range that matters: macro F1 moves from 0.9288 at 0.50 to a peak of 0.9372 at 0.81, a spread of 0.0084 over 45 points of threshold. 0.84 reads 0.9369 on the same curve, indistinguishable from the calibrated value. 0.84 is the reviewed value shipped before this retrain and is unchanged by it.

  • At the 0.5 default: 0.866
  • At the calibrated 0.91: 0.904

How to use it

Through the library, which is what this model is for. It loads the artifact below, applies the operating point above, and returns a decision with an evidence record rather than a bare score.

sh
pip install flowx-border
yaml
# policy.yaml
policy_id: default
version: 1

detectors:
  moderation:
    enabled: true
    on_fail: flag
    threshold: 0.91
python
from flowx_border import load_policy, scan_input, scan_output

policy = load_policy("policy.yaml")

decision = scan_input(user_text, policy)
decision = scan_output(model_answer, policy)

print(decision.verdict)      # allow | flag | redact | block
print([f.label for f in decision.findings if f.detector_id == "moderation"])
print(decision.evidence.record_id)

This detector reads the input and output side, so scan_input and scan_output is where it fires. It is T2, so it runs on the standard path and can be disabled per policy. Its budget is 150 ms at 87 tokens on one CPU thread.

The weights are fetched once and cached, and a scan needs no network after that. Nothing here calls out to a hosted model, and the evidence record carries hashes rather than your text.

Without the library

The artifact is plain ONNX, so it will load in onnxruntime directly. Two things you then own yourself, and they are the reason the library exists: the operating point above is not in the graph, and neither is the chunking. Inputs longer than the trained window have to be split and recombined, or the scores past it are extrapolation.

python
import onnxruntime as ort
from huggingface_hub import hf_hub_download
from tokenizers import Tokenizer

repo = "flowxai/moderation"
session = ort.InferenceSession(hf_hub_download(repo, "onnx/model.int8.onnx"))
tokenizer = Tokenizer.from_file(hf_hub_download(repo, "tokenizer.json"))

Per label

The table above asks whether the detector fires, this one asks which label applies, and they are different questions. A per-language row counts a sentence as correct when any label crosses the threshold, so it measures detection. Naming which kind is harder, and these are the numbers for it.

LabelSupportPRF1
cyber_intrusion1190.8460.8740.860
defamation1110.9730.9820.978
election_integrity1160.9910.9660.978
extremism1300.8620.8150.838
fraud_deception1240.8120.8390.825
hate_incitement1060.9440.9530.948
illicit_drugs1410.9610.8720.914
property_crime1290.8610.8140.837
self_harm990.8300.9390.881
sexual_exploitation1190.9830.9500.966
violent_facilitation1270.8880.8110.848
weapons_cbrn1330.9250.9250.925

Per language

Per language rather than an aggregate, because an aggregate across 26 languages hides the tail and the tail is the point.

LanguageSupportPRF1Note
bg Bulgarian521.0001.0001.000
it Italian610.9841.0000.992
pl Polish611.0000.9840.992
sl Slovenian591.0000.9830.992
el Greek571.0000.9830.991
de German541.0000.9820.991
lt Lithuanian521.0000.9810.990
da Danish511.0000.9800.990
en English620.9840.9840.984
et Estonian591.0000.9660.983
nl Dutch560.9820.9820.982
fi Finnish501.0000.9600.980
sk Slovak480.9790.9790.979
hu Hungarian630.9690.9840.976
ro Romanian631.0000.9520.976
hr Croatian600.9670.9830.975
fr French601.0000.9500.974
lv Latvian551.0000.9460.972
sv Swedish520.9620.9810.971
pt Portuguese520.9800.9620.971
cs Czech600.9830.9500.966
es Spanish521.0000.9230.960
tr Turkish600.9360.9830.959
az Azerbaijani570.9820.9300.955
ga Irish500.9130.8400.875
mt Maltese480.8720.8540.863not in base model pretraining

Weakest languages

Published rather than dropped. A coverage table with the bad rows removed is not a coverage table.

  • mt Maltese: F1 0.863 (absent from XLM-R pretraining, which is a base-model limit)
  • ga Irish: F1 0.875
  • az Azerbaijani: F1 0.955

Quantisation

The published artifact is INT8, quantising Gather.

For this artifact specifically: 2 of 300 decisions differ from the fp32 checkpoint, mean logit drift 0.0036, read as sigmoid_at_threshold. A quantised model that answers differently is a different detector, so this is measured rather than assumed.

Limitations

  • Synthetic training data. Generated natively per language, never translated from English, so the sentence structure is the target language's own. It is still synthetic, and a production distribution will differ.
  • Maltese is absent from XLM-RoBERTa's pretraining set. That is a fact about the base model, and it is not an explanation for a weak score. This card said "no amount of data fixes that" until 2026-08-14, which this project's own measurement disproves: the nsfw detector scored 0.000 in Maltese, was blamed on the base model, and went to 1.000 with perfect precision and recall when its corpus went from 2 positives per language to 10. Nothing about the model changed. So where a language scores badly here, read the support column first.
  • This is not a compliance product. It produces evidence about controls that were applied. It does not make anyone compliant with anything, and the obligations under the EU AI Act sit with the provider or deployer of a system, not with a model or a library.

Licence

Apache-2.0, declared in the metadata above as well as here, so that a tool reading the repository can attest it rather than a human having to read prose.