send-gate v7.2
Binary Dutch/Flemish + English teen-chat safety gate. It returns block or allow; there is no review band. Four learned branches: a 307M mmBERT classifier, a character n-gram branch, a policy branch for addresses/IPs/links/phrases, and a benign-suppression branch for privacy refusals and ordinary chat. No regex, no word lists.
The ONNX model uses an FP16 encoder and INT8 embeddings, keeps the full 256k vocabulary, and accepts dynamic message lengths.
Files
| File | Purpose |
|---|---|
model.onnx |
Main classifier. 419 MB. SHA256 308072d45ed95bac24bf6810d30ec9522967be3d64fbcc96fdb42b9bd232cfce. |
tokenizer.json |
256k tokenizer. |
tokenizer_config.json |
Tokenizer metadata for Hugging Face compatibility. |
ngram_model.npz |
Character n-gram branch. 1.5 MB. |
policy_model.npz |
Address/IP/link/policy branch. 1.6 MB. |
benign_model.npz |
Benign-suppression branch. 1.6 MB. |
gate.py |
Combined gate. |
serve.py |
HTTP server with web UI and JSON API. |
requirements.txt |
Server and gate dependencies. |
config.json |
Thresholds, precision and model metadata. |
Quick start
# 1. Clone
git clone https://huggingface.co/yamura4/send-gate-307m
cd send-gate-307m
# 2. Install (Python 3.11+)
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# 3. Start on port 8080, reachable from your LAN
python3 serve.py --host 0.0.0.0 --port 8080 --threads 4
# 4 GB Raspberry Pi only: add --no-mem-arena
Test it from another terminal:
# Health check
curl http://localhost:8080/healthz
# Block a known harmful term
curl -X POST http://localhost:8080/api/check \
-H 'Content-Type: application/json' \
-d '{"text":"kkrtest"}'
A 2 GB board is not recommended. serve.py downloads all five model files into model_cache/ if they are not next to it. It has no authentication or TLS; use a reverse proxy if exposed to the internet.
Python
from gate import SendGate
gate = SendGate(
model_path="model.onnx",
tokenizer_path="tokenizer.json",
ngram_model_path="ngram_model.npz",
)
print(gate.check("kkrtest"))
Benchmark
| Benchmark (804 items) | Score |
|---|---|
| Accuracy | 94.2% |
| Harmful caught | 95.6% (282/295) |
| Benign false walls | 6.7% (34/509) |
| False negatives | 13 |
| False positives | 34 |
Across all 1,793 evaluation items: 96.0% accuracy, 27 false negatives, 45 false positives. Held-out variants: 0 false negatives across 227 items.
The policy branch scores 99.7% recall on 2,000 held-out synthetic address/IP formats, with 0 false positives in 1,060 benign controls at threshold 0.85.
Policy examples
| Input | Verdict |
|---|---|
kkrtest |
block |
k4nkermoeilijke |
block |
je bent een omgekeerde regen |
block |
je bent een omgekeerde regen, grapje |
block |
omgekeerde regen |
block |
google.com |
block |
https://google.com |
block |
school.be |
block |
ik ga naar youtube.com |
block |
Kerkstraat 12, 9000 Gent |
block |
mijn ip is 192.168.1.1 |
block |
192 dot 168 dot 1 dot 1 |
block |
mijn huisadres zijn je zaken niet |
allow |
stuur geen links |
allow |
ik leef op een heuvel |
allow |
ja ik leef ook in herent |
allow |
ik woon dichtbij school |
allow |
straat |
allow |
de regen valt |
allow |
kwart voor 8 |
allow |
Architecture
| Branch | Detail |
|---|---|
| Main | mmBERT 307M, CLS pooling, byte-level character CNN, 768β256β1 head |
| Character n-gram | hashed character 2β5 grams, 2^18 features, learned logistic regression |
| Policy | hashed character 2β5 grams, trained on address/IP/link formats and policy phrases |
| Benign | hashed character 2β5 grams, trained on privacy refusals, link talk and common chat |
| Decision | block if main β₯ 0.94, n-gram β₯ 0.95, or policy β₯ 0.85; benign β₯ 0.99 suppresses a wall |
Deployment
| Metric | Value |
|---|---|
| Model on disk | 419 MB |
| ONNX Runtime session RSS | ~0.85 GiB |
| Full server RSS | ~1.29 GiB |
| Latency, Ryzen 7 3800X | ~22 ms short messages; ~100 ms at 128 tokens |
| Raspberry Pi | Pi 5: 4 GB minimum, 8 GB recommended |
| Pi speed | not measured; expect substantially slower than x86 |
The dynamic export requires exact token and byte lengths. Do not pad dynamic inputs with masked zeros; gate.py handles this automatically.
Limitations
- The address/IP/link branch is learned from synthetic formats. It is not a guarantee for every TLD, spacing trick or real-world address style.
ja jammerremains a known benign false wall.- Several decisions sit within a few thousandths of a threshold, so FP16 rounding can flip an edge item.
- Pi performance and ARM64 ONNX Runtime behaviour are not measured here.
License
MIT for the training code and gate. The backbone is jhu-clsp/mmBERT-base; check its license before commercial deployment.
- Downloads last month
- 528