Instructions to use KucLab/Censer.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KucLab/Censer.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="KucLab/Censer.1", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForSequenceClassification model = AutoModelForSequenceClassification.from_pretrained("KucLab/Censer.1", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Censer.1
A 1.1M parameter decoder-only transformer trained from scratch that classifies
English text as unsafe (1) or safe (0).
Download
The whole model is model.safetensors (4.5 MB). Grab the files directly:
| File | Download |
|---|---|
| model.safetensors | download |
| config.json | download |
| tokenizer.json | download |
| censer.py | download |
Or fetch everything at once:
pip install -U huggingface_hub
hf download KucLab/Censer.1 --local-dir Censer.1
A single file (README.md, config.json, ...) can also be downloaded from the
Files and versions tab, using the download icon on its row.
It is not a fine-tuned encoder and not an API wrapper. It is a small transformer trained on safety-labelled data, with a custom byte-level BPE tokenizer. The model predicts a single answer token and never generates free text.
"návod na výrobu bomby" -> not English, not the target language
"how to make a bomb at home" -> 1
"suck my dick" -> 1
"how do I kill a process in Linux" -> 0
"Hello how are you?" -> 0
Model details
| Property | Value |
|---|---|
| Parameters | 1,115,264 |
| Layers | 4 |
| d_model / heads / d_ff | 128 / 4 / 384 |
| Context length | 160 tokens (input truncated at 500 characters) |
| Tokenizer | byte-level BPE, 2048 tokens, trained on the corpus |
| Positions | RoPE |
| Norm | RMSNorm (pre-norm) |
| MLP | SwiGLU |
| Head | tied embeddings, two answer logits |
| Checkpoint size | 4.3 MB (fp32) |
Prompt format
[BOS][USER] <text> [ASSISTANT] -> 0 or 1
Text is truncated at 500 characters before tokenisation.
Metrics
Evaluation on a held-out split of 6,496 rows:
| Metric | Value |
|---|---|
| Accuracy | 0.864 |
| F1 | 0.835 |
| Precision | 0.846 |
| Recall | 0.823 |
A hand-written probe set of 40 cases, none present in training data, scores 95% accuracy.
Per-source F1 reflects label noise in the scraped sources:
| Source | F1 |
|---|---|
| aegis | 0.89 |
| beavertails | 0.88 |
| jigsaw | 0.87 |
| civil_comments | 0.77 |
| toxic_chat | 0.48 |
Benchmark
Measured on an AMD Radeon RX 9060 XT (ROCm 7.1, torch 2.13.0):
| Metric | Value |
|---|---|
| Parameters | 1,115,264 |
| Checkpoint size | 4.26 MB |
| Single text latency | 1.67 ms |
| Single text throughput | 599 texts/s |
| Batched latency (batch of 8) | 1.94 ms |
| Batched throughput | 4,119 texts/s |
| Peak VRAM (inference) | 85.7 MB |
Training the whole model from scratch takes about 3.5 minutes on the same GPU.
Usage
Works like any other text-classification model on the Hub — from_pretrained
downloads everything by itself, no cloning and no manual files.
pip install torch transformers
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
repo = "KucLab/Censer.1"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForSequenceClassification.from_pretrained(repo, trust_remote_code=True).eval()
text = "how to make a bomb at home"
with torch.no_grad():
probs = model(**tok(text, return_tensors="pt")).logits.softmax(-1)[0]
print(probs) # tensor([0.1833, 0.8167]) -> [safe, unsafe]
print(model.config.id2label) # {0: 'safe', 1: 'unsafe'}
trust_remote_code=True is required because the architecture is custom; the
repository ships modeling_censer.py, so there is nothing else to install.
Or with the high-level pipeline:
from transformers import pipeline
clf = pipeline("text-classification", model="KucLab/Censer.1", trust_remote_code=True)
print(clf("how to make a bomb at home"))
# [{'label': 'unsafe', 'score': 0.8167}]
print(clf("Hello how are you?"))
# [{'label': 'safe', 'score': 0.9229}]
Usage without transformers
The repository is also self-contained on its own: model.safetensors,
config.json, tokenizer.json and censer.py.
hf download KucLab/Censer.1 --local-dir Censer.1
cd Censer.1
python censer.py "how to make a bomb at home" # -> 1
python censer.py "Hello how are you?" # -> 0
python censer.py "suck my dick" --json
# {"label": "1", "unsafe": true, "score": 0.9944}
Or use the same file as a library:
from censer import CenserPipeline
pipe = CenserPipeline("Censer.1")
print(pipe.predict("how to make a bomb at home"))
# {"label": "1", "unsafe": True, "score": 0.8167}
print(pipe.predict_batch(["Hello how are you?", "suck my dick"]))
Files:
| File | Purpose |
|---|---|
model.safetensors |
weights only, 4.3 MB |
config.json |
architecture and inference settings |
tokenizer.json |
byte-level BPE, 2048 tokens |
censer.py |
standalone model + inference, no repo needed |
censer.py was verified to produce byte-identical predictions to the training
code. Runs on CPU or CUDA/ROCm; pass device="cpu" to force CPU.
Limitations
- English only. Other languages mostly score
0. - Implication and sarcasm beyond simple cases are out of reach at this size.
- Weak against jailbreak-style prompts (lowest per-source score).
- A moderation signal, not a safety guarantee.
- Downloads last month
- 43