heretic (p-e-w/heretic)

gpu
Searching Database…

35.9K ·GitHub
What is this?Heretic is a command-line tool that automatically removes censorship (safety alignment) from transformer-based language models using directional ablation combined with an Optuna-powered parameter optimizer, without any training.
Is this a CLI tool or does it need coding to use?It is a command-line program: you run a single `heretic` command and it handles the whole decensoring process automatically, no transformer internals knowledge required.
How do I decensor a model with it?Set up a Python 3.10+ environment with PyTorch, then run `heretic --model `, e.g. `heretic --model Qwen/Qwen3-4B-Instruct-2507`. Using `uv run heretic` after cloning the repo pins the exact dependency versions via the included uv.lock file.
What do I need installed before running it?Python 3.10+ and PyTorch 2.2+ (some features like loading MXFP4-quantized models such as gpt-oss need PyTorch 2.6+ for torch.accelerator). The project recommends uv for dependency management.
Does it work on any language model?It supports most dense models, many multimodal and MoE architectures, and some hybrid models like Qwen3.5, but pure state-space models and certain other research architectures aren't supported yet. A single run can also take 20-30 minutes on an RTX 3090 for a 4B model.
Does this need a powerful GPU?It's built around GPU-accelerated PyTorch and benchmarks were run on RTX 3090/5090 cards, but Heretic supports bitsandbytes quantization (bnb4bit) to drastically cut VRAM requirements for smaller setups.
How does the abliteration process actually work?For each transformer layer, Heretic identifies the attention out-projection and MLP down-projection matrices and orthogonalizes them against a 'residual direction' computed as the difference-of-means between first-token activations on harmful versus harmless prompts, suppressing that direction's expression.
How good are Heretic's results compared to manually abliterated models?In the README's comparison table, Heretic's gemma-3-12b-it version matched the refusal suppression of manual abliterations (3/100 refusals) but with much lower KL divergence from the original model (0.16 vs 0.45-1.04), meaning less damage to capabilities.
What can I do once a model is decensored?Heretic lets you save the resulting model locally, upload it to Hugging Face, chat with it interactively to test it, or run standard benchmarks on it, in any combination.
Is Heretic widely used already?The community has created and published well over 5000 models using Heretic, and independent benchmarks (MMLU, GSM8K) show favorable results compared to other abliteration tools.
Creator
p-e-w
Size
1.8 MB
Stars
35.9K
Age
1y
Commits · 90 Days