Heretic is a command-line tool that automates the process of "abliteration," a method for removing safety-related restrictions—often referred to as censorship—from transformer-based language models. Safety alignment typically involves training models to refuse requests deemed harmful, discriminatory, or offensive. Abliteration attempts to identify and modify the internal model weights responsible for these refusal behaviors, allowing the model to respond to a broader range of prompts. The tool utilizes an advanced implementation of directional ablation combined with a Tree-structured Parzen Estimator (TPE) optimizer powered by Optuna. This automated pipeline co-minimizes the number of refusals and the Kullback-Leibler (KL) divergence from the original model, a metric used to measure how much the modified model's output distribution deviates from the base version. By balancing these factors, Heretic aims to suppress refusal behaviors while preserving the model's original intelligence and capabilities. The process is designed to be accessible to users without deep knowledge of transformer internals, requiring only a Python environment and PyTorch. Once configured, the tool benchmarks the user's hardware to determine optimal batch sizes and executes the modification process, which can take between 20 to 45 minutes depending on the hardware and model architecture. While Heretic provides a streamlined approach to model modification, users should be aware of potential limitations. Abliteration modifies the model's internal state to bypass refusal mechanisms, but it does not necessarily restore information that was never encoded in the model during its initial training. Furthermore, while KL divergence metrics suggest that the modified models retain performance characteristics similar to the originals, these automated benchmarks may not fully capture qualitative changes in reasoning or the potential for increased hallucinations when the model is forced to generate responses it was previously trained to avoid.

Open Graph preview image for the Heretic GitHub repository
The Heretic project provides an automated pipeline for removing safety-related restrictions from language models.github.com

The article introduces Heretic as a command-line tool designed to automate the process of abliteration, which involves modifying model weights to remove safety-related refusal behaviors.