Instructions to use Bahushruth/gemma-4-E4B-it-abliterated with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Bahushruth/gemma-4-E4B-it-abliterated with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Bahushruth/gemma-4-E4B-it-abliterated") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Bahushruth/gemma-4-E4B-it-abliterated") model = AutoModelForMultimodalLM.from_pretrained("Bahushruth/gemma-4-E4B-it-abliterated", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Bahushruth/gemma-4-E4B-it-abliterated with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Bahushruth/gemma-4-E4B-it-abliterated" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Bahushruth/gemma-4-E4B-it-abliterated", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Bahushruth/gemma-4-E4B-it-abliterated
- SGLang
How to use Bahushruth/gemma-4-E4B-it-abliterated with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Bahushruth/gemma-4-E4B-it-abliterated" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Bahushruth/gemma-4-E4B-it-abliterated", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Bahushruth/gemma-4-E4B-it-abliterated" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Bahushruth/gemma-4-E4B-it-abliterated", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use Bahushruth/gemma-4-E4B-it-abliterated with Docker Model Runner:
docker model run hf.co/Bahushruth/gemma-4-E4B-it-abliterated
gemma-4-E4B-it-abliterated
Uncensored version of google/gemma-4-E4B-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 42 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 E4B uses an additional set of architectural defenses: four RMSNorm layers per decoder block, per-layer embeddings, and shared keys and values. These break the single-direction assumption of direction abliteration. Direction abliteration stopped at approximately 30 percent refusals inside the divergence budget. ARA reaches 2.7 percent refusals on the same evaluation set. This is the best documented abliteration result for Gemma 4 E4B with full methodology disclosure.
Fewer defenses does not mean easier: the standard Gemma 4 models (26B-A4B and 31B) drop per-layer embeddings and shared K/V, but add expert routing or extra capacity that makes them harder abliteration targets in practice.
Evaluation
| Metric | Result |
|---|---|
| Refusal rate (union, 500 prompts) | 2.7% |
| Refusal rate (enriched split, 350 prompts) | 2% |
| Refusal rate (mlabonne split, 150 prompts) | 3% |
| KL divergence from original model | 0.116 |
| Capability smoke battery | passed |
Original model refusal rate on the same prompts: 98 percent.
Usage
from transformers import AutoModelForImageTextToText, AutoTokenizer
import torch
model_id = "Bahushruth/gemma-4-E4B-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 E4B is a multimodal (text + vision + audio) model with approximately 8B parameters.
- Layers: 42
- Hidden size: 2560
- Attention heads: 8, KV heads: 2
- Defenses: four RMSNorm layers per block, per-layer embeddings (256 dimensions), 18 shared K/V layers
- Sliding window attention: alternates with full attention
Related Models
- Bahushruth/gemma-4-E2B-it-abliterated
- Bahushruth/gemma-4-26B-A4B-it-abliterated
- Bahushruth/gemma-4-31B-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{bahushruth2026gemma4e4b,
title={gemma-4-E4B-it-abliterated: Arbitrary Rank Ablation on Gemma 4},
author={Bahushruth},
year={2026},
url={https://huggingface.co/Bahushruth/gemma-4-E4B-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
- Downloads last month
- 110