Downloads · 30 days
0
asatheesh/latent-mas-aligner-qwen3-4b-seed-2
latent-mas-aligner-qwen3-4b-seed-2 is a machine learning model from asatheesh. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as apache-2.0.
LatentShield guards a latent multi-agent system: a LatentMAS pipeline in which the Planner, Critic and Refiner hand each other hidden states instead of text, and a Judger writes the only natural-language answer. Text…
Downloads · 30 days
0
Access
Public
Updated Nov 5, 2026
Repo size
109 MB
Likes
0
Public
Click a slice to open those files.
.pt109 MB · 100%
From the Hugging Face model README
LatentShield guards a latent multi-agent system: a LatentMAS pipeline in which
the Planner, Critic and Refiner hand each other hidden states instead of text, and
a Judger writes the only natural-language answer. Text moderators cannot see that
exchange without first decoding it. This checkpoint reads the pre-Judger latents
of a Qwen3-4B LatentMAS directly and scores
them with a frozen Llama-Guard tail. When p_unsafe exceeds tau, a safety notice
is placed in the Judger's prompt; otherwise the pipeline runs unchanged.
Qwen3-4B is the main backbone in our experiments. Undefended, its LatentMAS has the highest attack success of the five backbones we tested: 34.7% on HarmBench and 34.2% on StrongREJECT.
Sequential Planner → Critic → Refiner → Judger topology, direct requests, greedy decoding.
| HarmBench ASR ↓ | StrongREJECT ASR ↓ | OR-Bench-Hard RR ↓ | PHTest FRR ↓ | mean ↓ | |
|---|---|---|---|---|---|
| LatentMAS, no defense | 0.347 | 0.342 | 0.005 | 0.003 | 0.174 |
this checkpoint (p10) | 0.144 | 0.160 | 0.040 | 0.059 | 0.101 |
seed 0 (p10) | 0.134 | 0.163 | 0.012 | 0.062 | 0.093 |
seed 1 (p10) | 0.175 | 0.240 | 0.043 | 0.102 | 0.140 |
Of the three Qwen3-4B seeds, this one has the middle mean failure rate at p10 (0.101; the seeds span 0.093–0.140). Seed-to-seed spread is part of the result, so report all three rather than picking one.
h_a ∈ R^[B, 24, 2560], the 8 latent steps of each of the three pre-Judger agents.p(unsafe).aligner.pt, 109 MB).Each threshold is a quantile of seed 2's p_unsafe on benign validation rollouts: p10 is the value that 10% of them exceed. Seed 0 of this backbone was calibrated differently (on benign evaluation traffic, with a 25% point labelled p20), so its values are not comparable to these.
| operating point | flag rate on benign validation rollouts | tau |
|---|---|---|
p01 | 1% | 0.9373 |
p05 | 5% | 0.8383 |
p10 | 10% | 0.7138 |
p20 | 20% | 0.4321 |
p50 | 50% | 0.0049 |
The frozen Llama-Guard-3-8B tail (decoder blocks 17–31, final norm, LM head; 7.6 GB) is not included in this repo. Build it once from meta-llama/Llama-Guard-3-8B (a gated model; request access first) with python -m scripts.aligner.extract_cli --mode dump-head-bundle --layer 16 --out guard_head_bundle.pt.
Inside LatentMASHarmBench, point a config at the files:
# configs/model_configs/models.yaml (LatentMASHarmBench)
my_latentshield_cfg:
model:
model_name_or_path: Qwen/Qwen3-4B
mas_mode: latent_mas
latent_steps: 8
aligner_defense: true
aligner_path: aligner.pt # this repo's file
aligner_guard_head: guard_head_bundle.pt
aligner_tau: 0.7138 # p10 for this seed
The aligner only accepts Qwen3-4B latents (d_a = 2560, post-final-norm). It was
trained on direct requests and evaluated against them. The reported numbers are not
claims of robustness to adaptive attacks, and it is not a general-purpose content
classifier.
Code: LatentMASHarmBench · Collection: LatentShield