AI Tools / AI products & services
Heretic is a command-line tool for automatically removing safety alignment from transformer-based language models without post-training. It combines directional ablation (abliteration) with a Tree-structured Parzen Estimator optimizer powered by Optuna, co-minimizing refusal counts and KL divergence from the original model to select ablation parameters automatically.
For supported transformer components, currently attention output projections and MLP down-projections, Heretic computes per-layer residual directions from the difference between first-token hidden states for harmful and harmless prompts, then orthogonalizes the associated weight matrices against those directions. Its optimizer can interpolate between residual directions and select separate, flexible layer-weight kernels for different components. The tool supports most dense models, many multimodal models, several mixture-of-experts architectures, and some hybrid architectures; pure state-space models and certain research architectures are not supported out of the box.
Heretic runs in a Python 3.10+ environment with PyTorch 2.2 or later, supports optional bitsandbytes 4-bit quantization, and can save or upload generated models, launch a chat evaluation, and run standard benchmarks. An optional research installation provides residual-vector visualization using PaCMAP and residual-geometry analysis. The project is distributed under the GNU Affero General Public License version 3 or later.