license: gemma
base_model: google/gemma-4-31B-it
tags:
- abliteration
- uncensored
- gemma4
- multimodal
- arbitrary-rank-ablation
model_type: gemma4
pipeline_tag: image-text-to-text
datasets: - Bahushruth/abliteration-harmful-enriched
- mlabonne/harmless_alpaca
library_name: transformers
gemma-4-31B-it-abliterated
Uncensored version of google/gemma-4-31B-it with refusal behavior removed via arbitrary rank ablation (ARA).
Blog post: Abliteration part 2: Beating Google's guardrails (Gemma 4)
Method
ARA is a direct weight-editing method that solves a local optimization problem at each steerable matrix instead of projecting out a single global refusal direction.
| Parameter | Value |
|---|---|
| Steerable matrices | attention output projection + MLP down projection, all 60 layers |
| Loss | preserve harmless outputs + pull harmful outputs toward harmless + push away from original harmful outputs |
| Solver | LBFGS with strong-Wolfe line search |
| Row norms | preserved exactly by reparameterization (grimjim method) |
| Search | Optuna TPE, 60 trials, union objective |
| Harmful dataset | Bahushruth/abliteration-harmful-enriched (7356 prompts, 35 categories, 10 phrasing styles) |
| Harmless dataset | mlabonne/harmless_alpaca |
| Infrastructure | Modal A100-80GB |
Why ARA and not direction abliteration
Gemma 4 31B keeps only the four RMSNorm layers per decoder block as architectural defenses. It drops the per-layer embeddings and shared K/V used by the E models. Direction abliteration reached 18 percent refusals at KL 0.028. ARA reaches 4.0 percent refusals on the same evaluation set. The 60 layers and 5376 hidden size give the model enough capacity to route around a weak edit, which is why the local, matrix-by-matrix approach of ARA wins over a single global direction.
Evaluation
| Metric | Result |
|---|---|
| Refusal rate (union, 500 prompts) | 4.0% |
| Refusal rate (enriched split, 350 prompts) | 3% |
| Refusal rate (mlabonne split, 150 prompts) | 5% |
| KL divergence from original model | 0.283 |
| Capability smoke battery | passed |
Original model refusal rate on the same prompts: 96 percent.
Usage
from transformers import AutoModelForImageTextToText, AutoTokenizer
import torch
model_id = "Bahushruth/gemma-4-31B-it-abliterated"
model = AutoModelForImageTextToText.from_pretrained(
model_id,
dtype=torch.bfloat16,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
messages = [{"role": "user", "content": "Your prompt here"}]
text = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
with torch.no_grad():
output = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Architecture Notes
Gemma 4 31B is a multimodal (text + vision + audio) model with approximately 33B parameters.
- Layers: 60
- Hidden size: 5376
- Attention heads: 32, KV heads: 16
- Defenses: four RMSNorm layers per block, attention K=V
- Sliding window attention: alternates with full attention
Related Models
- Bahushruth/gemma-4-E2B-it-abliterated
- Bahushruth/gemma-4-E4B-it-abliterated
- Bahushruth/gemma-4-26B-A4B-it-abliterated
Disclaimer
This model has had safety guardrails removed. It will comply with requests that the original model would refuse. The creator takes no responsibility for how this model is used. It is released for research purposes to study AI alignment and safety mechanisms.
Citation
@misc{bahushruth2026gemma431b,
title={gemma-4-31B-it-abliterated: Arbitrary Rank Ablation on Gemma 4},
author={Bahushruth},
year={2026},
url={https://huggingface.co/Bahushruth/gemma-4-31B-it-abliterated}
}
Acknowledgments
- p-e-w/heretic for arbitrary rank ablation (ARA)
- grimjim for norm-preserving weight editing
- mlabonne for the harmless dataset and abliteration technique
- Google for the Gemma 4 family