license: apache-2.0
base_model: Qwen/Qwen3-4B
language:
- en
tags: - qwen3
- abliterated
- uncensored
- directional-ablation
- gguf
- transformers
pipeline_tag: text-generation
Qwen3-4B-Abliterated
An abliterated (refusal-direction orthogonalized) version of Qwen/Qwen3-4B, created without fine-tuning using targeted residual-stream directional ablation on Kaggle Dual T4 (fp16).
Files Included
fp16Safetensors (model*.safetensors): Full-precision (float16) weights fortransformers/vLLM.qwen3-4b-abliterated-Q4_K_M.gguf: 4-bit quantized GGUF (~2.5 GB) forllama.cpp, Ollama, LM Studio, and mobile/CPU inference.
Method Summary
- Base Model:
Qwen/Qwen3-4B(float16) - Direction Extraction: Computed normalized refusal direction
r = normalize(mean(harmful) - mean(harmless))on 256+256 training prompts frommlabonne/harmful_behaviorsandmlabonne/harmless_alpaca(enable_thinking=False). - Best Layer: Layer
19(of36) selected via inference-time hook sweep across middle layers (14..27). - Weight Orthogonalization: Applied
W <- W - λ · r · rᵀ · W(λ = 1.0) toself_attn.o_projandmlp.down_projacross targeted middle layers14..26(preservingembed_tokensand early/late layers to minimize KL drift).
Evaluation Results
Evaluated on held-out test splits (100 harmful prompts, 100 harmless prompts, and 100 MMLU questions):
| Metric | Base (Qwen/Qwen3-4B) |
Abliterated (14..26, λ=1.0) |
|---|---|---|
| Harmful Refusal Rate (Thinking OFF, 100 prompts) | 96.0% | 13.0% |
| Harmful Refusal Rate (Thinking ON, 30 prompts) | — | 13.3% |
| Harmless Next-Token KL Divergence | 0.0000 | 0.2073 |
| MMLU (100-question subset) | 67.0% | 66.0% (-1.0%) |
Usage (transformers)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "rahulpro579/Qwen3-4B-Abliterated"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto",
)
messages = [{"role": "user", "content": "Explain how TCP differs from UDP in 3 bullet points."}]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False,
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
with torch.inference_mode():
out = model.generate(**inputs, max_new_tokens=256, do_sample=False)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Notes & Limitations
- Behavior: Refusal guardrails have been significantly reduced; outputs are not filtered for safety. Users are responsible for downstream deployment and compliance with the Apache 2.0 license.