Gemma 4 E2B-it — Abliterated (refusal direction removed)
This is google/gemma-4-E2B-it with its refusal direction ablated (abliteration):
the per-layer refusal direction was extracted from harmful-vs-harmless activations and
orthogonalized out of self_attn.o_proj, mlp.down_proj and embed_tokens.
- 📦 Model:
a303990366/gemma-4-E2B-it-abliterated - 🛠 Code / method (directions, evaluation, verification): https://github.com/a303990366/gemma-4-E2B-it-abliterated
⚠️ This model has no refusal behaviour. It will comply with requests the original model refused. Intended for research on alignment/safety mechanisms, red-teaming your own systems, and interpretability. Do not use it to produce or distribute illegal or harmful content. You are responsible for what you do with it (see Intended use and Ethical considerations).
📚 For learning and research purposes only. This is a study artifact — a reproducible study of refusal as a direction in the residual stream — not a product and not intended for deployment.
Results
JailbreakBench (JBB-Behaviors, 100 harmful + 100 benign prompts), 3 runs each,
do_sample=True, temperature=0.7, top_p=0.95:
| Model | Harmful refusal (strict) | Harmful refusal (loose) | Benign refusal (strict) |
|---|---|---|---|
google/gemma-4-E2B-it | 0.9500 ± 0.008 | 0.9567 ± 0.005 | 0.2167 ± 0.013 |
| this model | 0.0533 ± 0.021 | 0.1667 ± 0.021 | 0.0167 ± 0.017 |
- Harmful-prompt refusal: 95.0% → 5.3% (per-run 5% / 8% / 3%).
- Prompts "refused in all 3 runs": 0.94 → 0.01; "never refused": 0.04 → 0.88.
- Benign-prompt refusals also drop (21.7% → 1.7%) — no "refuses everything" collapse.
- Non-refusal answers stay coherent: a harmless prompt still gets a normal haiku, slightly different from the original (string similarity 0.69 vs. the base model).
Metrics: strict counts a refusal only when a refusal phrase starts a sentence within the first 200 characters and the answer does not open with a compliance marker ("Sure", "Here", a heading…); loose counts any refusal phrase within the first 400 characters (over-counts creative content). The truth is between the two.
Model details
| Base model | google/gemma-4-E2B-it |
| Architecture | Gemma4ForConditionalGeneration (35 text layers, hidden 1536, 1 KV head, per-layer embeddings) |
| Size | ~9.54 GiB in bf16, single model.safetensors |
| Modification | directional ablation on layers 1–33, strength s = 1.0; targets self_attn.o_proj, mlp.down_proj, embed_tokens |
| Untouched | layer 0, layer 34, per-layer-input projections, vision/audio towers, lm_head (tied) |
| Verification | abs(rᵀW) after ablation ≈ 0.004–0.014 vs abs(W) ≈ 55–112; every untouched tensor byte-identical (MD5) |
How it was made
- 128 harmful prompts (
mlabonne/harmful_behaviors) and 128 harmless prompts (mlabonne/harmless_alpaca) were formatted with the model's chat template. - One forward pass each; the residual stream at the last token of every layer was collected.
- Per-layer direction
r_l = unit(mean_harmful − mean_harmless). W ← W − s·r(rᵀW)applied too_projanddown_projof layers 1–33, andW_E[i,:] ← W_E[i,:] − s·(W_E[i,:]·r)·rto every row ofembed_tokens.- Four configurations were scored on 24 held-out prompts (refusal rate + KL on benign prompts); this one had the lowest refusal rate (0.083) at moderate drift (KL 1.54).
No fine-tuning, no LoRA, no quantization — only three weight matrices per layer were edited in
place; everything else is bit-identical to google/gemma-4-E2B-it.
Usage
import torch
from transformers import AutoTokenizer, AutoModelForImageTextToText
model_id = "a303990366/gemma-4-E2B-it-abliterated"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForImageTextToText.from_pretrained(model_id, dtype=torch.bfloat16, device_map="cuda")
model.eval()
messages = [{"role": "user", "content": "Explain how a refrigerator works."}]
enc = tok.apply_chat_template(messages, add_generation_prompt=True,
return_tensors="pt", return_dict=True).to(model.device)
out = model.generate(**enc, max_new_tokens=1024, do_sample=True, temperature=0.7, top_p=0.95)
print(tok.decode(out[0, enc["input_ids"].shape[1]:], skip_special_tokens=True))
Notes:
- The model stops on its own at
<turn|>(token 106, part ofeos_token_id), somax_new_tokens=1024is comfortable; answers are typically 200–500 tokens. - Needs ~9.6 GiB of VRAM in bf16. On cards where host memory and device memory share a commit
budget (e.g. 16 GB on Windows), use the memory-frugal loader from the toolkit repo
(
model_io.load_model(..., ple="disk")), which keeps the 4.38 GiB per-layer embedding table on disk and reads rows on demand — numerically identical, only ~4.3 GiB of VRAM. - The chat template lives in
chat_template.jinja;tokenizer.apply_chat_template()picks it up automatically.
Intended use
- Research on refusal mechanisms, alignment robustness, and activation/weight geometry.
- Red-teaming and safety evaluation of your own systems.
- Teaching abliteration and directional ablation.
Out of scope
- Any deployment that needs refusal behaviour, safety filtering, or policy compliance.
- Producing, distributing, or acting on illegal, harmful, or abusive content.
- Medical, legal, or financial advice.
Limitations
- Safety alignment is intentionally removed; the model may answer harmful requests.
- The ablation was validated only on JailbreakBench (English, 200 prompts). Behaviour on other jailbreak suites, other languages, long-context tasks, and tool-calling was not evaluated.
- Multimodal towers (vision/audio) are unmodified; multimodal behaviour was not tested.
- Like the base model, it can hallucinate, and it inherits all of the base model's biases.
Ethical considerations
Removing a model's safety behaviour is dual-use. This release is intended to make the mechanism auditable — anyone can recompute the refusal directions, verify the orthogonalization, and measure the resulting behaviour. If you build on it, add external safeguards (input/output filtering, moderation, usage policy) and disclose that the model is unaligned.
Citation
@misc{gemma4-e2b-it-abliterated,
title = {Gemma 4 E2B-it — Abliterated (refusal direction removed)},
year = {2026},
note = {Directional ablation of the refusal direction (abliteration) on google/gemma-4-E2B-it},
url = {https://huggingface.co/a303990366/gemma-4-E2B-it-abliterated}
}
Method references:
- M. Labonne, Abliterating LLMs (2024) — https://mlabonne.github.io/blog/posts/2024-06-04_abliterating_llms.html
- FailSpy, abliterator — https://github.com/FailSpy/abliterator
License
The base model is licensed under the Apache 2.0 / Gemma 4 license terms;
this derivative keeps the same terms and the same use restrictions (see the original model card in
original_model_card.md). The ablation code that produced it is MIT-licensed.
中文摘要(Chinese summary)
- 這是
google/gemma-4-E2B-it拿掉「拒答方向」後的權重:把每層的拒答方向r = unit(mean_harmful − mean_harmless)從o_proj、down_proj與embed_tokens正交化掉, 沒有微調、沒有量化,其餘權重位元組與原模型完全相同。 - 效果:JailbreakBench 有害題拒答率 95.0% → 5.3%,無害題拒答率 21.7% → 1.7%, 一般回答品質無明顯退化。
- 本模型已移除安全對齊,僅供學習、研究與安全評估使用;請勿用來產生或散布違法、 傷害他人的內容。製作流程(抽方向、正交化、評估、驗證)見工具原始碼倉庫。