safeguard-classifier
Cheap rules first, a 20B safety model second. A classifier for harmful AI conversations that degrades gracefully without a GPU.
- Kind
- Security
- Year
- 2026
- Links
- Code ↗
- Views
- Python
- HuggingFace Transformers
- gpt-oss-safeguard-20b
- Docker
- NVIDIA GPU
The problem
Moderating AI conversations needs to be both fast and nuanced. Rules alone miss context; a large model alone is slow, costly and a single point of failure.
What I did
- Stage 1: regex and keyword rules, with zero added latency.
- Stage 2: if nothing matched, a local
openai/gpt-oss-safeguard-20bscores the conversation on GPU. - If the GPU or the model is unavailable, the service falls back to rules only instead of failing.
- A small HTTP API (
POST /classify,GET /health) returns{ violation, confidence }, packaged with Docker Compose.
Architecture
- conversationPOST /classify
- rules.pyregex · keywords
- gpt-oss-safeguard-20bonly if no rule fired
- { violation, confidence }response
Results
- stages: rules, then model
- 2
- parameter safety model, run locally
- 20B
- endpoint to integrate
- 1
- downtime when the GPU is missing
- 0
Next case
NutriDz