Spaces:
Paused
Add Shield+ tab: six judgements from one pass and your own safety categories
Follow-up to #1, per the request for more of Shield's capabilities in the playground. Adds a Shield+ tab next to Shield (the plain request-safety tab from #1 is unchanged).
What it shows, from one forward pass of Shield's label-conditioned head (lc/):
- request harm, prompt attack, and the request's hazard categories;
- with an optional response: response harm, refusal, and response hazard categories;
- your own safety categories (experimental): 2–8
name: descriptionlines, ranked by a softmax across the list.
The tab downloads only lc/ plus the root tokenizer and config (~1.26 GB), so it uses one model-cache slot. With VELA_MODEL_CACHE_SIZE=2, switching between Safety, Shield and Shield+ never held more than two language models (peak ~2.6 GB).
Thresholds: thresholds.json in the Shield repo covers the fixed heads only, not lc/, so every judgement here uses 0.5 and the tab says so.
Examples, verified by real inference on CPU with torch 2.8.0 / transformers 4.57.6 (request harm / attack / response harm / refusal, %):
| example | scores | categories above 0.5 |
|---|---|---|
| cocaine request, refused | 99.82 / 0.01 / 0.003 / 99.99 | Controlled/Regulated Substances, Criminal Planning |
| journalist's home address, answered with fictional details | 99.91 / 0.03 / 99.99 / 11.36 | PII/Privacy (request and response) |
| duplicate-charge refund, helpful reply | 0.96 / 0.004 / 0.02 / 0.05 | none |
| party balloons | 0.70 / 0.003 | none |
| email with an injected instruction | 12.82 / 96.76 | none |
The built-in category set (violence / privacy / drugs / fraud) ranked the intended label first on 8 of 8 probe requests.
Measured limit, stated in the tab and README: categories far from Shield's trained safety labels do not transfer. Customer-support intents and workplace-policy sets collapsed onto one label (1 of 4 correct; nine rephrasings at most 2 of 4), so they are not offered as examples. Also dropped: "How do I kill a Python process?" scores 84.9% unsafe on this head.
Checks: 107 unit tests pass (11 new); the Space engine matches lc/load_lc.py within 2.7e-7; /api/analyze on the running app returned identical scores for every example; headless Chrome keeps all 16 tabs in one row from 980 to 1920 px. Not checked on the Space's own CPU Basic hardware.