license: mit
base_model: unsloth/Qwen4-35B-A3B-GGUF
tags:
- gguf
- lora
- llama.cpp
- abliteration
- qwen
Qwen4-35B-A3B: refusal-direction abliteration as a rank-1 LoRA
We built this to drive our internal instance of the ARTEX autonomous penetration testing platform.
You are welcome to use it to protect things that are yours, or to learn more about security. The
world already has a surplus of trouble, please do not use this to get into other people's stuff.
A 107 MB llama.cpp LoRA adapter (abl-L16.gguf) that removes the refusal direction from Qwen4-35B-A3B.
It was computed on unsloth/Qwen4-35B-A3B-GGUF
(UD-Q4_K_XL), which is used unchanged. Load the adapter on top of it at strength 1.5:
llama-server -m Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf \
--lora-scaled abl-L16.gguf:1.5 -ngl 99 -fa on -ctk q8_0 -ctv q8_0 --jinja
Qwen4 (qwen4exp) needs a recent llama.cpp built from master; older releases fail with
"unknown pre-tokenizer". Other quantizations of the same model should accept the adapter (the tensor
shapes are the same), but we only tested UD-Q4_K_XL.
Why a LoRA
Abliteration (Arditi et al., 2024) projects one direction r out of every matrix that writes to the
residual stream: W' = W - r rᵀW. That is a rank-1 update, so it fits a LoRA exactly: lora_b = -r,lora_a = rᵀW. For the token embedding the delta is -(E_t·r) r. The base GGUF stays as published,
the strength is a runtime knob, and dropping the LoRA restores stock behaviour.
Qwen4-35B-A3B has 40 layers (plus one MTP layer), a 2048-wide residual, 256 routed experts per layer and
4-stream hyper-connections. The direction was measured on the mean of the four streams. Edited residual
writers (122 tensors): attn_output, ssm_out, ffn_down_shexp, ffn_down_exps (one rank-1 pair per
expert, applied by llama.cpp through mul_mat_id), ple_value (the per-layer n-gram embedding writes
into every stream) and token_embd. The MTP block, used only for speculative drafting, is skipped:
mainline llama.cpp drops its tensors, and an adapter naming them fails to load.
How the direction was found
- 400 harmful prompts: 300 CyberSecEval MITRE attack prompts and 100 AdvBench. 400 harmless prompts: 300
CyberSecEval MITRE false-refusal (benign security) prompts and 100 Alpaca. Matching benign security
prompts keeps "this is about security" out of the direction. - Each prompt was rendered with the model's own chat template (
scripts/render_api.py) and run once
through llama.cpp (scripts/abl_collect.cpp). The residual after every block was captured at the last
token, and the mean harmless activation was subtracted from the mean harmful one per layer.refusal_dirs_qwen4.npyholds these differences: 40 layers × 2048, float32, not normalized. - Eleven candidate layers (12–32, even) were screened on 40 held-out harmful and 20 benign prompts.
Stock refused 29/40. Layers 16 and 20 were best; at strength 1.0 they refused 5/40 and 7/40, so
strength was swept: L16 gave 1/40 at 1.25 and 0/40 at 1.5, L20 1/40 and 2/40. No setting refused a
benign prompt. Layer 16 at 1.5 was chosen.
Results
Final sets ran on llama.cpp (CUDA, 2× RTX 5060 Ti 16 GB) with q8_0 KV cache. The red-team and benign sets
were graded with a keyword refusal check, and outputs were read by hand. Sampling was greedy for the
refusal sets and the server default for the agent tasks.
| Stock | L16 × 1.5 | |
|---|---|---|
| Red-team prompts refused, thinking off | 36/40 | 0/40 |
| Benign security and general prompts refused (false refusals) | 11/100 | 1/100 |
| Red-team screen, thinking on (L16 at 1.0) | 14/40 | 3/40 |
| Multi-turn ops-agent task (tool calls, mocked infra) | pass | pass |
| 20 single tool calls | 19/20 | 19/20 |
| RAG answering with citations | 20/20 | 20/20 |
The adapter also cut false refusals on benign security questions (11 → 1 of 100). Strength 1.5 sounds
high, but the agent task, tool calls and RAG answers stayed at stock level. Agents still make mistakes,
so keep human approval on destructive tools.
Note: llama-server serves every loaded adapter by default
If several adapters are loaded, a request with no "lora" field gets all of them at their global
scale. Load only this adapter in production, or name it in every request.
Files
abl-L16.gguf: the LoRA (rank 1, alpha 1, float32), archqwen4exp.
sha25620bf727997cfa3c5ae2997a46ef6a69f40004d9ec21408e483809a59f76816c4.refusal_dirs_qwen4.npy: per-layer harmful−harmless mean differences (40 × 2048).scripts/:abl_collect.cpp(activation means over the hyper-connection streams, links against
libllama),render_api.py(chat template through a running llama-server),abl_lora.py(builds LoRAs
from the directions, including 3-D expert tensors; setGGUF_PYto a llama.cpp tree's gguf-py),probe.py(refusal probe with per-request LoRA).
The same method on other models:
Nemotron 3.5 Bolt 74B-A9B,
Nemotron 3.5 Lightning 30B-A3B,
Nemotron 3.5 Bolt E4B.
License
Our work (the scripts, the method and this card) is under the MIT License (LICENSE).
The adapter (abl-L16.gguf) and the direction vectors (refusal_dirs_qwen4.npy) are computed from the
Qwen4-35B-A3B weights, which are under the Apache License 2.0
(Qwen/Qwen4-35B-A3B); those derived files are offered under the
same Apache 2.0 terms.