p-e-w/heretic
Fully automatic censorship removal for language models
What it solves
Heretic removes "safety alignment" (censorship) from transformer-based language models. It aims to stop models from refusing to answer prompts while preserving as much of the original model's intelligence and capabilities as possible, avoiding the expensive post-training typically required for such modifications.
How it works
Heretic uses a technique called directional ablation (or "abliteration"). It identifies "residual directions" in the model's hidden states—the difference between how the model processes "harmful" versus " harmless" prompts. It then orthogonalizes the model's weight matrices (specifically attention out-projection and MLP down-projection) to inhibit the expression of those refusal directions.
To make this process automatic, Heretic uses a TPE-based parameter optimizer (via Optuna) to find the best ablation parameters. It optimizes for a balance between minimizing refusals and minimizing the KL divergence from the original model to ensure the model doesn't become "broken" or lose intelligence.
Who it’s for
- LLM Users: People who want uncensored versions of existing models without needing deep knowledge of transformer internals.
- AI Researchers: Those studying model interpretability and the semantics of model internals, as the Heretic
researchextra provides tools for plotting residual vectors and analyzing residual geometry.
Highlights
- Fully Automatic: No manual tuning of ablation parameters is required; the tool finds the optimal settings automatically.
- Broad Support: Works with most dense models, various MoE architectures, and hybrid models like Qwen3.5.
- Flexible Ablation: Uses a flexible weight kernel and linear interpolation of residual directions to find better directions than simple layer-by-layer ablation.
- Interpretability Tools: Includes features to generate PaCMAP projections and animations of residual vectors to visualize how the model's internal states transform across layers.
Related
- Dispatch
- Dispatch
- Project
- Project
- Dispatch