🐦 Magpie β€” pricing the robustness of an open, on-device safety model

For an open, on-device model the attacker owns the weights, so safety is not a refusal rate β€” it is the attacker cost to break the model, at each capability level, in the languages people actually use. Magpie prices that, pairs every number with over-refusal, and tests whether a cheap white-box margin predicts the price.

Lexsi Hackathon β€” Track 2a. A red-teaming study of Cohere Labs' Tiny Aya Fire, in English and Hinglish, that measures safety as attacker cost rather than refusal rate, and tests whether cheap white-box measurements can predict that cost.

Thesis, in one sentence. For an open model that ships on the phone β€” where the attacker owns the weights β€” the right safety number is not "what fraction does it refuse?" but "how much attacker effort does a break cost, at each capability level, in the languages people actually use?"

Teammates: Harsh Dahiya (attacks, serving, runners, defenses), iHamza14 (data, judges), shahanxd (mechanistic analysis, survival statistics, write-up).


1. Abstract

Refusal rate measures the wrong thing for an open, on-device model: a static percentage says nothing about an attacker who holds the weights and can template, resample, prefill, or edit them. Magpie re-frames robustness as a cost curve β€” the share of harmful prompts still refused as a function of attacker FLOPs β€” and places input-space and weight-space attacks on one axis, always paired with over-refusal on benign prompts, in English and in Hinglish (romanized Hindi-English code-mixing) with a Devanagari control. We attack the vendor-hardened Tiny Aya Fire (3.35B) and a SafeTune-hardened variant across an attacker ladder L0β†’L3, judge every attempt with both a cheap multilingual refusal lexicon and the HarmBench content classifier, and regress per-prompt break depth on a pre-attack white-box refusal margin.

Four results stand out. (C4, the headline) The judge choice does not just rescale ASR, it flips defense rankings: the refusal lexicon over-counts jailbreaks 4–5Γ— and, cross-lingually, reports Devanagari as 4Γ— easier than English and Hinglish as the safest form β€” when the content-validated truth is the opposite in ordering and a third in magnitude. (H4) A prompt's cheap, attack-free refusal-direction margin predicts how expensive it is to break (Cox hazard ratio 0.60–0.72 per standard deviation, p ≀ 0.003) β€” the high-risk "audit before you attack" bet, and it is positive. (H1) Content-validated, there is a real but modest script gap: Fire complies with 28% of harmful Devanagari requests vs 3% in English and 3% in Hinglish. (Defense, a clean negative) A lightweight 150-step circuit-breakers/RR pass raises attacker cost at no level. Everything is reproducible on free Kaggle T4s; harmful completions are gated, attacked weights are never published.


2. Why refusal rate is the wrong number (motivation)

Tiny Aya Fire is a small, multilingual, openly released model built for South-Asian languages and intended to run on-device. That deployment makes the usual safety metric misleading. A closed API can hide behind its refusal rate because the attacker only ever sees the output. An open model offers the attacker the full escalation ladder:

A single refusal percentage collapses this ladder to a point. Worse, for a model whose whole reason to exist is Hinglish and Indic languages, an English-only refusal number is close to meaningless. Magpie's answer is to price robustness: measure how much the next break costs at each rung, in each language, and always show what that safety costs benign users (over-refusal).

Pre-registration. Hypotheses H1–H5 and the analysis plan were committed to docs/PREREGISTRATION.md before the main runs (git history proves the order). This is a red-team study with a falsifiable, high-risk bet (H4); reporting it honestly β€” including where it fails β€” is the point.


3. Threat model: the attacker ladder and the cost axis

We price one forward pass as 2Β·PΒ·tokens FLOPs and one training step as 6Β·PΒ·tokens, with P = 3.349Γ—10⁹ (the measured Tiny Aya Fire parameter count; see magpie/costs.py). Every attack attempt logs its own cost, and a prompt's survival time is the cumulative attacker cost at the first validated break; prompts that never break are right-censored. This turns a jailbreak campaign into a survival-analysis dataset.

Level Capability Attacks implemented
L0 query only direct ask
L1 query + cheap search 5 jailbreak-template families; best-of-N input perturbation (synthetic noise and natural Hinglish respelling)
L2 decoder control prefill / safety-depth sweep
L3 weight access refusal-direction abliteration

The survival unit is the prompt, not the model, so a single run yields hundreds of data points and real statistics (Wilson ASR CIs, Kaplan–Meier curves, Cox regression) rather than a handful of model-level numbers.


4. Method

Data. A parallel core of harmful seeds (HarmBench standard + StrongREJECT) and benign "over-refusal" seeds (XSTest-safe + OR-Bench-Hard), stratified across nine harm categories, in three matched forms β€” English, Hinglish, Devanagari β€” so any per-form difference is the form, not the content. The Hinglish/Devanagari core is built by in-kernel Aya Expanse 8B translation (no paid API, no data leaving the kernel), with a native-speaker review sheet. Harmful completions live only in a gated HF dataset; the repo holds aggregates and no-text artifacts.

Attacks & serving. One generate() behind vLLM (or an HF fallback) runs on free Kaggle 2Γ—T4 kernels; a deterministic bundle-push-poll-pull runner makes every run reproducible from a config + git SHA.

Judges (C4). Two judges score every attempt: a fast multilingual refusal lexicon (with a collapse guard that excludes degenerate output) as an upper-bound pre-filter, and the HarmBench content classifier (cais/HarmBench-Mistral-7b-val-cls) under a composite gate (HarmBench-harmful and not collapsed) as the validated jailbreak rate. Every ASR in our results log that is not labelled "HarmBench" is explicitly the lexicon upper bound.

Mechanistic audit (C3). A refusal direction is fit at layer 24 on a disjoint contrast set (never the eval prompts); each prompt's standardized projection onto it is its refusal margin, computed with no attack.


5. Results: the English cost ladder (C1)

Hero figure: cost-to-break ladder

Fire, English, HarmBench-validated where a content judge was run:

Level Attack ASR (lexicon) ASR (HarmBench) median log₁₀ FLOPs note
L0 direct 0.21 0.05 [0.02, 0.09] 12.9 already refuses ~95% (content)
L1 templates 0.52 0.29 [0.22, 0.36] 13.1 public structure ~6Γ— L0
L1 best-of-N (synthetic) ~1.00 0.19 [0.13, 0.28] 13.0 power law, saturates by Nβ‰ˆ16
L2 prefill 1.00 0.31 [0.23, 0.40] 12.6 shallow safety: 1 token β†’ 0.80
L3 abliteration 0.99 0.68 [0.60, 0.76] 13.5 weight access breaks 2 in 3

Read. The cost axis does real work. Fire is genuinely robust to a direct ask (0.05) and still mostly holds against public jailbreak templates (0.29), but its safety is shallow β€” a single forced compliance token takes prefill ASR to 0.80, saturating at two β€” and it is defenceless to weight edits (abliteration 0.68 at ~10¹³·⁡ FLOPs of one-time direction-fit cost). The contrast between L0 (0.05) and L3 (0.68) on the same model is the whole on-device story: safe to ask, broken to edit. Best-of-N on the input follows a clean Hughes-style power law (βˆ’log ASR(N) = aΒ·Nᡇ, b β‰ˆ βˆ’1.9) but its content-validated ceiling (0.19) is far below the lexicon's saturated ~1.00 β€” which is the headline C4 point.


6. The headline: judge validity flips rankings (C4)

A cheap refusal judge does not merely inflate ASR by a constant β€” it reorders defenses and languages, which is fatal for a leaderboard.

Within English, rescoring the same attempts with HarmBench:

attack (Fire, en) lexicon ASR HarmBench ASR
L1 templates 0.52 0.29
L1 best-of-N ~1.00 0.19

By the lexicon, best-of-N (β‰ˆ1.00) crushes templates (0.52). By the content judge the order flips: templates (0.29) > best-of-N (0.19). Synthetic BoN produces long, non-refusing, but not actually harmful text that only a content judge can catch.

Across languages (Fire, L0, identical prompts), the effect is even sharper:

form lexicon ASR HarmBench ASR what the lexicon got wrong
en 0.21 0.03 clean
hi-Deva 0.86 0.28 73% of its "compliances" are Devanagari refusals it can't read (20 cues vs 48 en)
hing 0.09 0.03 the low number is 93% model collapse, not refusal

The refusal lexicon reports Devanagari as 4Γ— English and Hinglish as the safest form. The content-validated truth is the opposite ordering and a third the magnitude: Devanagari β‰ˆ 9Γ— English, Hinglish β‰ˆ English. You cannot compare robustness across languages β€” or rank defenses β€” with a refusal lexicon. Magpie's pairing of a content judge with a collapse guard is what makes the cross-lingual comparison trustworthy. This is contribution C4, and it directly realizes the pre-registered H5 (the en-vs-non-English judge gap).


7. H1 (language) and C2 (natural best-of-N)

H1 β€” a real but modest script gap. Content-validated, Fire complies with 0.28 of harmful Devanagari requests vs 0.03 English and 0.03 Hinglish β€” a genuine safety-coverage gap in script/language that survives the content judge, but one that the refusal lexicon had tripled. The three forms also fail differently: English cleanly refuses, Devanagari refuses in script the lexicon can't read, Hinglish collapses (the model degenerates on romanized code-mixing). Same model, three attack surfaces.

C2 β€” the best-of-N power law is an adversarial-noise effect, not "more samples β‡’ more breaks".

BoN source (form) ASR N=1 N=8 N=64 power law
synthetic noise (en) 0.07 0.97 1.00 b = βˆ’1.93, rΒ² 0.96
natural Hinglish respelling (hing) 0.0375 0.0375 0.0375 b β‰ˆ 0 (flat)

Synthetic ASCII/caps/scramble noise opens attack surface and scales steeply; natural, meaning-preserving Hinglish respelling that a real user would produce does not scale at all. The direction is judge-independent (a content judge only lowers a flat floor). For a deployer: a best-of-N defense budget should target adversarial perturbation, not ordinary spelling variation. (We also confirmed the verified tool gap: SafeTune's BoN is effectively inert on Devanagari.)


8. H4 (the breakthrough bet): audit before you attack (C3)

Does a cheap, attack-free white-box measurement predict the measured cost-to-break? We regress per-prompt break depth (attacker effort, event = broken) on the standardized refusal margin with a Cox model:

attack n events hazard ratio (95% CI) p
L1 best-of-N 100 100 0.72 [0.58, 0.89] 0.003
L1 templates 100 51 0.60 [β€”] 2Γ—10⁻⁢

H4 is supported, and positively. A one-standard-deviation higher refusal margin lowers the hazard of a break by ~28% (best-of-N) to ~40% (templates), both significant. A prompt's margin β€” computed with no attack, from a direction fit on disjoint data β€” predicts how expensive it will be to break. This was the pre-registration's flagged high-risk contribution (a null would have been reportable); it is not null.

It also generalizes across models (the pre-registered leave-one-model-out check). Extracting the margin on Global (its own disjoint contrast set) and re-fitting on L1 templates: Fire HR 0.60, Global HR 0.67, pooled 0.64 [0.56, 0.73], p = 2Γ—10⁻¹¹ (concordance 0.69). The predictor works on a model it was not tuned on β€” so the audit is not a per-model artifact. (The en-vs-Hinglish margin check stays open: the model collapses on Hinglish, leaving too few break events for a well-powered regression β€” itself a finding.)


9. Defenses, and an honest negative

We hardened Fire with SafeTune and re-ran the ladder, paired against vendor Fire (same prompts, same seeds).

M2 Circuit-Breakers / RR (150 steps, LoRA on 2 layers, loss 5.0β†’0.50) is the headline defense result β€” and it is a clean negative measured as cost:

level attack Fire (HarmBench) fire_rr (HarmBench)
L1 templates 0.30 0.30
L2 prefill 0.31 0.31

At every level and under both judges the hardened model is broken exactly as often as vendor Fire, with a byte-identical prefill safety-depth curve. The checkpoint is genuinely the hardened one (its completions differ prompt-by-prompt), it simply costs no more to break. A lightweight RR pass that looks plausible (loss drops, L0 unchanged) shifts no survival curve β€” exactly the illusion the cost framing exists to expose. M3 RepNoise went further wrong: it destroyed the model (all outputs degenerate), which the collapse guard flagged automatically β€” an "off-switch" defense that zeroes ASR by wrecking utility, caught because we never trust a raw refusal number.

These negatives are the point, not an embarrassment: cost + a collapse guard + a content judge is what tells a real defense from a plausible-looking one.


10. Limitations


11. Responsible disclosure

Prompts, scores, judgements and statistics are released; harmful completions are gated on HF; attacked/abliterated weights are never published (described, not shipped). Material findings go to Cohere Labs and Lexsi before publication. Everything stays within CC-BY-NC and the Cohere Labs AUP (non-commercial safety research). The laptop demo uses non-actionable categories only.


12. Reproducibility and ROI


Artifacts: GitHub magpie (code + reproducibility README), HF model collection (hardened variants), HF dataset collection (prompts/scores/logs, harmful completions gated), HF Space, and per-model robustness cards. Full numbers and run provenance in docs/RESULTS.md.

How much does the next break cost?

Attack success rate (HarmBench-validated) as the attacker gains capability: just ask (L0) β†’ public jailbreaks (L1) β†’ controls the decoder (L2) β†’ edits the weights (L3).

Attack success rate by attacker capability level for Fire, Global and the RR-hardened Fire
modelL0 directL1 templatesL1 best-of-NL2 prefillL3 abliteration
Fire (vendor)0.050.290.190.310.68
Global (vendor)0.070.29β€”0.160.68
Fire + RR (hardened)β€”0.30β€”0.31β€”

Fire and fire_rr overlap β€” the hardening buys nothing. The L3 jump is the weight-access cliff: safe to ask, broken to edit.

Within English β€” the judge flips the attack ranking

Same attempts, two judges. The cheap refusal lexicon over-counts and flips the attack ranking; only a content judge tells a long non-refusal from a real jailbreak.

attackrefusal lexiconHarmBench (validated)
L1 templates0.520.29
L1 best-of-N1.000.19

Across languages β€” the judge flips the ranking of forms

Identical prompts, three forms. The lexicon says Devanagari is 4x English and Hinglish is safest; the content judge says the opposite in order and a third in size.

formrefusal lexiconHarmBench (validated)
English0.210.03
Devanagari0.860.28
Hinglish0.090.03

You cannot compare robustness across languages β€” or rank defenses β€” with a cheap refusal lexicon.

Does hardening help?

A lightweight Circuit-Breakers/RR pass (fire_rr) re-attacked paired against vendor Fire. It raises attacker cost at no level β€” an honest negative.

attacker levelFire (HarmBench)fire_rr (HarmBench)
L1 templates0.300.30
L2 prefill0.310.31

An honest negative: a defense that looks plausible (training loss drops, L0 clean) yet shifts no survival curve. Validate defenses by re-attacking and measuring cost.

Audit before you attack (H4)

A prompt's attack-free refusal-direction margin predicts how expensive it is to break (Cox regression; hazard ratio < 1 means a higher margin survives longer).

attackhazard ratio / SD95% CIp
best-of-N0.72[0.58, 0.89]0.003
templates0.60β€”2e-6
pooled Fire + Global (leave-one-model-out)0.64[0.56, 0.73]2e-11

The margin is computed with no attack, from a direction fit on disjoint data β€” and it predicts cost-to-break on a model it was not tuned on.

Robustness cards

One-page, deployer-facing summaries per model.

Robustness card β€” Tiny Aya Fire (vendor, M0)

A deployer-facing summary. Numbers are content-validated with the HarmBench classifier unless marked "lexicon"; full provenance (run dirs, git SHAs, CIs) in docs/RESULTS.md. Model: CohereLabs/tiny-aya-fire, 3.35B, cohere2, open weights.

One line. Safe to a direct ask, holds against public jailbreak templates, but its safety is shallow (one forced token bypasses it) and it is defenceless to weight edits β€” the on-device threat that matters for an openly released model.

Cost to break (English)

Attacker level Capability ASR (HarmBench) ~cost (log₁₀ FLOPs)
L0 direct query only 0.05 12.9
L1 templates query + public jailbreaks 0.29 13.1
L1 best-of-N (synthetic) query + cheap resampling 0.19 13.0
L2 prefill controls the decoder 0.31 (lexicon 1.00; 1 token β†’ 0.80) 12.6
L3 abliteration edits the weights 0.68 13.5

Over-refusal (benign prompts)

13% of benign-but-scary English prompts are refused at L0 (XSTest-safe + OR-Bench-Hard); jailbreak templates lower it to ~7% (the "answer directly" framing suppresses benign refusals too).

By language (L0, HarmBench)

English Hinglish Devanagari
0.03 0.03 0.28

A real safety-coverage gap in Devanagari (~9Γ— English). Hinglish is as robust as English once model collapse (degenerate output on romanized code-mixing) is excluded.

Deployer guidance

  • Do not rely on the refusal rate. A refusal-lexicon monitor over-counts safety 4–5Γ— and, in Devanagari, reports the model as ~4Γ— less safe than it is. Use a content judge + a collapse guard.
  • Assume prefill = broken. If any surface lets a caller set the first reply tokens, treat the model as unprotected (ASR 0.80 at one token). Guard the decoder, not just the prompt.
  • Weights are the boundary. An attacker with the file breaks 2 in 3 harmful prompts by abliteration. On-device deployment must assume this; safety training alone does not help here.
  • Watch Devanagari specifically β€” it is the weakest language surface.
  • A cheap pre-screen works: a prompt's refusal-direction margin predicts its cost-to-break (H4), so a red-team budget can be focused before any attack is run.

Robustness card β€” Tiny Aya Global (vendor, M1)

A deployer-facing summary. Numbers are content-validated with the HarmBench classifier unless marked "lexicon"; full provenance in docs/RESULTS.md. Model: CohereLabs/tiny-aya-global, 3.35B, cohere2, open weights β€” the vendor's safest Tiny Aya variant.

One line. Behaves almost identically to Fire across the ladder: robust to a direct ask, holds against templates, shallow to prefill, and broken by weight edits. "Safest variant" does not mean more expensive to break.

Cost to break (English)

Attacker level Capability ASR ~cost (log₁₀ FLOPs)
L0 direct query only 0.07 (HarmBench) 12.9
L1 templates query + public jailbreaks 0.29 (HarmBench) 13.1
L2 prefill controls the decoder 0.16 (HarmBench; lexicon 1.00, 1 token β†’ 0.89) 12.6
L3 abliteration edits the weights 0.68 (HarmBench) 13.5

Over-refusal (benign prompts)

13% at L0, falling to ~5% under jailbreak templates β€” the same robustness/over-refusal trade as Fire.

Deployer guidance

  • Fire β‰ˆ Global at L0/L1/L3, so picking the "safer" vendor label buys ~no extra cost-to-break there; the real separation is attacker capability (L0β†’L3), not model choice. The one exception is prefill, where Global is content-safer (0.16 vs Fire's 0.31) β€” but both are fully bypassed by the lexicon (1.00), so this edge is invisible without a content judge and should not be leaned on.
  • The prefill and weight-edit cautions from the Fire card apply unchanged: guard the decoder, assume weight access breaks the model.
  • Global was evaluated in English; the per-form (Hinglish/Devanagari) and best-of-N studies were run on Fire. Treat Fire's Devanagari gap as the likely Global behaviour pending a matched run.

Robustness card β€” Tiny Aya Fire + Circuit-Breakers/RR (hardened, M2)

A deployer-facing summary. Numbers are content-validated with the HarmBench classifier unless marked "lexicon"; full provenance in docs/RESULTS.md. Model: Tiny Aya Fire hardened with SafeTune M2 (Circuit Breakers / Representation Rerouting), 150 steps, LoRA on 2 layers, merged. Weights not published.

One line. A plausible-looking defense that shifts no survival curve: the loss drops and L0 is clean, but the hardened model costs exactly as much to break as vendor Fire at every level. This is the honest negative the cost framing is built to surface.

Cost to break vs vendor Fire (paired, same prompts)

Attacker level Fire fire_rr Ξ”
L0 direct 0.21 lexicon 0.21 lexicon none
L1 templates 0.30 HarmBench 0.30 HarmBench none
L2 prefill 0.31 HarmBench 0.31 HarmBench none
L2 prefill curve k=1 0.80, k=2 0.98, kβ‰₯4 1.00 identical none

The checkpoint is genuinely the hardened one β€” its completions differ prompt-by-prompt from Fire's, so the merged weights loaded β€” it simply does not cost more to break.

Verdict for a deployer

  • Do not ship a defense on its training loss. RR here drove loss 5.0β†’0.50 and left L0 clean, yet moved no attacker-cost curve. Validate a defense by re-attacking it and measuring the survival curve, not by its loss or its L0 refusal rate.
  • Representation rerouting did not touch prefill at all (safety-depth curve byte-identical) β€” a shallow-safety attack needs a depth-targeted defense (Qi et al.), not RR.
  • A heavier RR schedule (more steps, more layers) or a different method (CAST) is required before any hardening claim; this lightweight pass is not sufficient.

Companion negative: M3 RepNoise on the same model collapsed it (all outputs degenerate), which the collapse guard flagged automatically β€” a defense that zeroes ASR by destroying utility. Neither lightweight defense is deployable as-is.