kcnet-guard-lite: compact content-safety detectors

Small, fast, single-purpose detectors that decide "escalate or not" before a large guard model is ever loaded. Text, image, audio and video stages, each with an exact I/O contract.

Overview

Content-safety traffic is dominated by the benign case. Running a generative guard LLM on every message is both slow and wasteful, so this repository provides the first stage: compact classifiers and distilled students that return a two-class score in milliseconds. Ambiguous traffic is escalated to the generative guard tier.

The artifacts are deliberately heterogeneous β€” a DeBERTa encoder for text, EfficientNet students for image and audio, a 3D CNN for temporal video, and a few linear probes over frozen teacher features. Each one is published with the contract measured from the file itself: input shape, normalisation, threshold. No artifact here is a chat model.

Repository contents

Artifact Size Architecture Input contract Output
content_safety/fast_text_guard/pytorch/model.safetensors 1.1 GB DeBERTa encoder + 2-way classifier head (202 tensors) token ids + attention mask 2 logits
content_safety/fast_text_guard/onnx/model.onnx 1.1 GB same, exported token ids + attention mask 2 logits
content_safety/text_qa_guard/model.joblib 1.8 MB scikit-learn pipeline over hashed text features raw text 2-class label
content_safety/image_student_guard/image_student_guard.pt 16 MB EfficientNet-B0, 224 px, ImageNet norm (N, 3, 224, 224) float32 2 logits, threshold 0.5
content_safety/image_student_guard/image_student_guard.onnx 16 MB same, opset 17 input (batch, 3, 224, 224) float32 logits (batch, 2)
content_safety/image_student_guard_vlguard/image_student_guard.{pt,onnx} 16 MB each same backbone, vision-language label teacher (batch, 3, 224, 224) (batch, 2)
content_safety/image_guard/image_guard.npz 434 KB MLP 225 β†’ 512 β†’ 2 over frozen features, with mean/std 225-dim feature vector 2 logits
content_safety/image_guard/teacher_features.npz 6.2 MB reference set: 7,039 rows of 220-dim teacher embeddings + 3-class teacher probabilities β€” β€”
content_safety/multimodal_guard_image/model.npz 7 KB linear model over 560-dim fused features 560-dim vector 1 logit
content_safety/image_deep_guard_lora/adapter_model.safetensors 149 MB LoRA (r=16, alpha=32) on Qwen/Qwen2.5-VL-3B-Instruct, attention + MLP chat messages free-form verdict
content_safety/qwen_guard_lora/adapter_model.safetensors 132 MB LoRA (r=16, alpha=32) on a Qwen2.5-based guard base chat messages free-form verdict
content_safety/audio_student_guard/audio_student_guard.pt 31 MB EfficientNet-B2 over 128-bin log-mel 16 kHz mono, 5 s clip, n_fft 1024, hop 512 2 logits, threshold 0.985
content_safety/video_student_guard/video_student_guard.pt 16 MB EfficientNet-B0, 8 frames per clip, max aggregation (N, 8, 3, 224, 224) clip threshold 0.94
content_safety/video_temporal_guard/video_temporal_guard.pt 46 MB MC3-18 (3D CNN), Kinetics norm (N, 8, 3, 112, 112) 2 logits, threshold 0.84

Every contract above was read from the shipped file, not from training notes. Re-verify with onnx.load(...) or torch.load(...) if you re-export.

Quick start

import numpy as np, onnxruntime as ort

session = ort.InferenceSession("content_safety/image_student_guard/image_student_guard.onnx")
batch = np.random.rand(1, 3, 224, 224).astype(np.float32)
unsafe = session.run(["logits"], {"input": batch})[0][0, 1]
print("unsafe score:", unsafe)
import torch

ckpt = torch.load("content_safety/video_temporal_guard/video_temporal_guard.pt", map_location="cpu")
print(ckpt["architecture"], ckpt["image_size"], ckpt["frames_per_clip"], ckpt["decision_threshold"])
# mc3_18 112 8 0.84

The .pt files are dictionaries, not bare state_dicts: architecture, preprocessing constants and decision thresholds travel with the weights, so a loader never has to guess them.

Artifacts

Text stage

fast_text_guard is the main workhorse: a DeBERTa encoder with a two-way head, exported to ONNX for runtime-independent deployment. text_qa_guard is the ultra-cheap tier β€” a scikit-learn pipeline over hashed text features that fits in 1.8 MB and is meant for volume pre-filtering, not for borderline decisions.

Image stage

Three levels of cost. image_student_guard is an EfficientNet-B0 distilled from a larger teacher; the _vlguard variant is the same backbone labelled by a vision-language teacher instead, kept because the two teachers disagree in useful ways. image_guard is a two-layer MLP over 225-dim frozen features β€” 434 KB, the cheapest possible gate β€” and multimodal_guard_image is a single linear layer over 560 fused features.

teacher_features.npz is published alongside the probe on purpose: it holds 7,039 rows of 220-dim teacher embeddings with labels and 3-class teacher probabilities, so the probe can be retrained and audited.

Audio and video stages

audio_student_guard classifies 5 s, 16 kHz clips through 128-bin log-mel features. It ships two thresholds: a strict one (0.985) for final decisions and a permissive fast-path threshold (0.206) for a first pass.

video_student_guard scores 8-frame clips with max aggregation; the clip-level threshold (0.94) is separate from the frame threshold (0.49). video_temporal_guard is a genuine 3D CNN (MC3-18) at 112 px, which catches motion patterns a frame classifier misses, at 3x the size.

Adapters

Two LoRA adapters fine-tune generative bases into verdict emitters: one on Qwen/Qwen2.5-VL-3B-Instruct for image content, one on a Qwen2.5-based guard base for text. Both are r=16, alpha=32 over attention and MLP projections and must be applied to the stated base β€” they are not standalone models.

Intended use

  • Tier-0 filtering in front of a generative guard model.
  • On-device moderation where a network round-trip is unacceptable.
  • Fast triage of user uploads before storage or further processing.
  • A worked example of distillation into 16 MB students with explicit thresholds.

Out of scope

  • Final enforcement decisions on borderline content; the escalation path exists for a reason.
  • Detecting prompt injection, malware or network attacks β€” this is content safety only.
  • Biometric identification or any analysis of who is in an image.
  • Running the adapters without their stated base models.

Limitations

  • Binary heads: the severity granularity of the generative guard tier is not available here.
  • Thresholds were tuned for one deployment distribution. Changing domain invalidates them; recalibrate on your own validation split.
  • The probes over frozen features can only be as good as the teacher that produced those features; the published feature set is the reference distribution.
  • Aggregation over clips hides short violations surrounded by benign frames. Lower the clip threshold if that matters more than false positives.
  • Per-artifact accuracy numbers are not published on this card. The contracts above are exact; quality claims are not. Validate on your own labelled sample before deployment.

License and provenance

Detectors trained in this project. The two adapters require bases licensed separately (Qwen/Qwen2.5-VL-3B-Instruct and a Qwen guard base) β€” check those licenses before redistribution. DeBERTa and EfficientNet backbones follow their upstream licenses.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support