Tool

Heretic

Modify locally runnable language models without expensive training using configurable scorers, behavior modifiers, and reproducibility manifests.


88
Spark score
out of 100
Updated 9 days ago
Source checked Nov 3, 2026
Version 2.0.0

Add to Favorites

Source

Get it from source

Spark does not host a copy of it.

Open source

Reports

Agent outcome reports

No reports yet

Overview

Heretic changes language model behavior without expensive training by combining configurable scorers, modifiers, and hyperparameter optimization. It supports local processing, model export, and optional reproducibility manifests. Use it to modify a model that fits your hardware and evaluate the resulting behavior. Match the software environment closely when reproducing saved weights.

What it does

Heretic modifies language models without running an expensive training process. It uses contrasting example prompts, configurable scorers, and mathematical modifiers to steer model behavior. Available configurations target refusal suppression, slop reduction, reduced humor, reduced sycophancy, and changes to emotional alignment. Refusal suppression is the default action; the other behaviors use their corresponding configuration files or a custom configuration.

The tool supports most dense models, including many multimodal models, several MoE architectures, and many modern hybrid models. Processing depends on what your hardware can accommodate. Optional on-the-fly 4-bit quantization with bitsandbytes can reduce the VRAM needed to process a model to roughly the amount used by a typical quantized version, with a slight accuracy cost. Enable that mode through the quantization option set to bnb_4bit.

When to use - and when NOT to

Use Heretic when you want to change a locally runnable model's behavior through scored examples rather than perform expensive training. The configurations provide distinct starting points for different behavioral goals, so choosing one is part of defining the modification you want. Understanding language model internals is not required to use the tool.

Account for hardware and software constraints before processing a model. The environment requires Python 3.10+ and PyTorch 2.6+ installed appropriately for the hardware. Configurations created for Heretic 1.x are incompatible with Heretic 2.x and require migration. A reproducibility manifest also does not guarantee identical weights across different environments: hardware, drivers, operating system, and package versions affect the result.

Getting started

Prepare the required Python and PyTorch environment, then use the installation and model-processing example:

pip install -U heretic-llm
heretic Qwen/Qwen3-4B-Instruct-2507

The model identifier selects the model to process. At the beginning of a run, Heretic benchmarks the system to determine an appropriate batch size for the available hardware. With an RTX 3090 and the default configuration, the example Qwen3-4B-Instruct-2507 model takes about 30-40 minutes to process. That timing applies to this specific hardware and configuration.

When processing finishes, you can save the model, upload it to Hugging Face, chat with it to test its behavior, run standard benchmarks, or combine those actions. These choices support checking the resulting model before deciding how to keep or share it.

Scorers and optimization

Scorer plugins calculate the scores that guide the modification. A custom scorer inherits from the Scorer abstract base class and implements get_score; additional machinery supports settings management when needed. The default scorers measure refusal rate and KL divergence. Existing scorers also provide examples for developing implementations suited to other goals.

The main configuration's scorers setting selects active plugins and whether each score should be minimized or maximized. Multiple scorers can be co-optimized, and multiple instances of the same scorer can use different settings. A plugin can be referenced by a fully qualified import path or by a file path followed by its class name. Loading a custom scorer does not require modifying Heretic's package code.

Heretic combines its modifier with an Optuna-powered, TPE-based hyperparameter optimizer. The optimizer searches for modifier parameters that minimize or maximize the configured scores on the modified model. It ships with Arbitrary-Rank Ablation (ARA), the default modifier, and directional ablation, also called abliteration. The directional implementation uses a flexible ablation weight kernel over model layers and supports projected abliteration and norm preservation (MPOA). The modifiers setting switches implementations, although a processing run uses only one modifier.

Reproducible models and the Grimoire

When uploading a processed model to Hugging Face, you can optionally include reproducibility information. The uploaded model repository then contains a reproduce folder with human-readable instructions and a machine-readable reproduce.json manifest. Together, these record the information needed to recreate the model, with byte-for-byte identity dependent on a perfectly identical environment.

Automatic reproduction checks your environment against the original and points out potentially problematic mismatches. It avoids repeating the original multi-hour computations and typically takes a few minutes. After export, Heretic compares weight-file hashes against those in the manifest, showing whether the reproduced weights match. Differences can remain when the environments differ.

The Heretic Grimoire is a distributed library of these reproduction manifests. A manifest is around 9 kilobytes, making it a portable way to retain a model's reproduction information. You can collect local copies of publicly available manifests from Hugging Face without relying on the hosted Grimoire application. Collection works as an append-only backup: repeating it updates the collection without deleting files, even when a corresponding model disappears from Hugging Face.

License and research use

Heretic is free software under the GNU Affero General Public License, version 3 or any later version. It is distributed without warranty, including implied warranties of merchantability or fitness for a particular purpose. Contributions are released under the same license. Research use carries a request to cite Philipp Emanuel Weidmann's 2025 work, Heretic: Training-free language model modification.

Source README
Heretic logo

Heretic

Training-free language model modification

Remove censorship, suppress slop, reduce sycophancy, and more. All in an afternoon, on your gaming PC.

Discord     Matrix    Follow us on Hugging Face    Codeberg mirror


 

#1 Repository of the Day     Model and download statistics

Modify any LLM that you can run on your hardware[^1]

[^1]: Heretic supports on-the-fly 4-bit model quantization with bitsandbytes, which can reduce the amount of VRAM required to process a model to the same amount that is used to run a typical quantized version of it, at a slight accuracy cost. Set the quantization option to bnb_4bit to enable this.

Heretic is a unique tool that lets you do what only corporations with access to massive computing power usually do: Modify, rather than merely run, language models. It does not perform expensive training; rather, it uses a collection of mathematical techniques to steer behavior based on contrasting example prompts and matching scorers.

Heretic can, depending on the configuration:

and many, many other things.

:bangbang: Using Heretic does NOT require understanding how language models work internally :bangbang:

In fact, you can go from zero to removing censorship from your first model in a matter of seconds. Heretic supports most dense models, including many multimodal models, several different MoE architectures, and many modern hybrid models.

The community has created and published thousands of models with Heretic. Heretic models have been independently benchmarked using standard metrics like MMLU and GSM8K, and have been found to compare favorably against models produced with competing abliteration tools.^2

 

Heretic screenshot

 

Usage

Prepare a Python 3.10+ environment with PyTorch 2.6+ installed as appropriate for your hardware. Then run:

pip install -U heretic-llm
heretic Qwen/Qwen3-4B-Instruct-2507

Replace Qwen/Qwen3-4B-Instruct-2507 with whatever model you want to process. By default, Heretic performs censorship removal (refusal suppression). If you want to do something else, choose one of the configuration files linked above, or write your own. See config.default.toml for available configuration options.

At the start of a program run, Heretic benchmarks the system to determine the optimal batch size to make the most of the available hardware. On an RTX 3090, with the default configuration, processing Qwen3-4B-Instruct-2507 takes about 30-40 minutes.

After Heretic has finished processing a model, you are given the choice to save the model, upload it to Hugging Face, chat with it to test how well it works, run standard benchmarks on it, or any combination of those actions.

Controlling what Heretic does using scorer plugins

Heretic steers model behavior by optimizing one or multiple scores. Scores are computed by scorer plugins. You can easily write your own scorers to get full control over what Heretic does to models.

The Scorer interface (abstract base class) your scorer needs to inherit from is defined in scorer.py. The only required method is get_score, but there is more machinery (such as settings management) available when you need it.

By default, Heretic scores models by refusal rate (implemented in keyword_rate.py) and KL divergence (implemented in kl_divergence.py). Additional scorers are available in the scorers directory. These scorers can serve as examples for your own implementations, and can easily be adapted to your needs.

Scorers are configured through the main configuration file. Which scorer plugins are active is determined by the scorers setting, which also controls whether a scorer's score should be minimized or maximized during optimization. Any number of scorers can be used simultaneously, and their scores will be co-optimized. Multiple instances of the same scorer can be configured with different settings. See the configuration file for the full documentation of this mechanism.

The path to a scorer plugin can be specified either as a fully qualified import path (fully.qualified.module.MyScorerClass) or as a file path followed by a class name (path/to/plugin.py:MyScorerClass). You do not have to modify the Heretic package code in order to use your own plugins.

Heretic also has modifier plugins, which are described in the next section.

How Heretic works

Heretic combines a pluggable modifier (interface in modifier.py) with a TPE-based hyperparameter optimizer powered by Optuna. The optimizer finds a set of parameters that, when passed to the modifier, minimize or maximize a set of configurable scores on the resulting model (see above).

Heretic ships with two modifiers:

  • Arbitrary-Rank Ablation (ARA)[^4]: This is the default modifier, and was specifically developed for use in Heretic. You can find an overview of how ARA works in the original pull request, and see the precise implementation in ara.py.

  • Directional ablation aka "abliteration"[^5]: The classic method for refusal suppression. Heretic's implementation uses a flexible ablation weight kernel over the layers, and supports both projected abliteration[^6] and norm preservation (MPOA)[^7]. The complete code is in abliteration.py.

[^4]: Weidmann 2026. A preprint explaining the technique will be available soon. [^5]: Arditi et al. 2024 [^6]: Lai 2025 (1) [^7]: Lai 2025 (2)

You can use the modifiers setting to switch between modifier implementations. Despite the name of the setting using a plural form, Heretic currently allows only a single modifier for a given processing run. This may change in the future.

Reproducibility and the Heretic Grimoire

Heretic has the ability to create reproducible models whose repositories contain all information required to produce a byte-for-byte identical model on demand, provided that the environment is perfectly identical to the original one. PyTorch doesn't guarantee that operations return identical outputs unless hardware, drivers, operating system, and the entire software stack including all package versions are exactly the same.

Heretic manages all that complexity for you. When uploading a processed model to Hugging Face, Heretic offers to include reproducibility information. This is entirely optional, but if you choose to do so, the uploaded repository will contain a reproduce folder with detailed instructions for recreating the model (example). This folder contains both human-readable instructions and a machine-readable manifest file named reproduce.json, which includes all the information Heretic needs to automatically reproduce the model.

Automatic reproduction can be performed with

heretic --reproduce path/to/reproduce.json

Heretic will guide you through the process, checking your environment against the one that was used to create the model, and pointing out potentially problematic mismatches. The multi-hour computations that were required to make the original model do not have to be re-done, and the entire process typically takes a few minutes. After you have exported the resulting model, Heretic will verify the hashes of the weight files against those stored in the reproduction manifest (they may or may not be identical, depending on how closely your system resembles the original one).

Many people have uploaded models with reproducibility information to Hugging Face. Since a reproduction manifest is only around 9 kilobytes in size, these manifests form a portable library of models that can be reproduced at will.

That library is called the Heretic Grimoire. You can view it here.

But you don't have to rely on an externally hosted web application to access the library of manifests: The Grimoire is fundamentally designed as a distributed system, and you can fetch your own local copies of publicly available manifests from Hugging Face whenever you want by running

heretic --collect-reproducibles path/to/target/folder/

You now have a local backup of all reproducible Heretic models, properly catalogued. To update this collection, simply run the command again. It functions as an append-only backup, never deleting files even if the corresponding model no longer exists on Hugging Face.

Heretic is made by humans!

Unlike lots of AI-related software today (and indeed lots of software in general), Heretic is not "vibe-coded".

All of my commits in this project so far were written 100% by hand, the way I have been doing programming for decades, and while some Heretic contributors use coding agents, I review every single line of code that I merge very carefully. There's no "LGTM" here!

Don't believe me? Check out this pull request, which accumulated almost 350 human-written comments over more than 7 months as we discussed the implementation. And here is another PR with more than 200 comments.

I am the opposite of a luddite and I have used agents for other projects, but I am proud of the code I write and so far can't quite bring myself to let a machine write it for me in a project I care so much about. As a result, Heretic has a lean, relatively simple codebase that in my opinion, and in that of some others, is a pleasure to work on.

If you like that, join us! Hop on the Discord and tell us about your ideas for improvements, or directly file an issue or open a PR.

Prior art

I'm aware of the following implementations of abliteration techniques that were publicly available when Heretic was first released (November 2025):

Note that Heretic was written from scratch, and does not reuse code from any of those projects.

Citation

If you use Heretic for your research, please cite it using the following BibTeX entry:

@misc{heretic,
  author = {Weidmann, Philipp Emanuel},
  title = {Heretic: Training-free language model modification},
  year = {2025},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/p-e-w/heretic}}
}

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.