Note
This repository (ai-security) is a community continuation of Heretic.
The original project was created by Philipp Emanuel Weidmann and its contributors.
It was archived on 28 November 2026, with the author
inviting the community to carry it on
without naming a successor. This repository preserves the complete upstream commit
history and continues development from the final upstream commit (cd315cb).
- This continuation is not affiliated with or endorsed by the original author.
- The license is unchanged: AGPL-3.0-or-later. All original copyright notices are retained.
- The Python package, the
hereticcommand, and the configuration format are unchanged for now. - Development here is AI-assisted. The text below is based on the original upstream README and will be revised as the project evolves — see the roadmap.
Remove censorship, suppress slop, reduce sycophancy, and more.
All in an afternoon, on your gaming PC.
Modify any LLM that you can run on your hardware1
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:
- Suppress refusals/remove censorship (this is the default action)
- Reduce slop (
config.noslop.toml) - Reduce humor (
config.nohumor.toml) - Reduce sycophancy (
config.nosyco.toml) - Alter emotional alignment (
config.emotions.toml) - Shorten response length (
config.terse.toml)
and many, many other things.
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.23
Prepare a Python 3.11+ environment with PyTorch 2.6+ installed as appropriate for your hardware. Then run:
pip install -U heretic-llm
heretic Qwen/Qwen3-4B-Instruct-2507Replace 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, and the
configuration guide for how to write a configuration
file and use your own prompts. Heretic loads the configuration from
config.toml in the working directory by default, or from the file path in the
HERETIC_CONFIG_FILE environment variable.
Important
Configuration files made for Heretic 1.x are not compatible with Heretic 2.x! See the migration guide for what you need to change in order to make your old configurations work.
Heretic processes prompts in large batches to make the most of the available hardware, and halves the batch size automatically whenever the GPU runs out of memory. On an RTX 3090, with the default configuration, processing Qwen3-4B-Instruct-2507 takes about 30-40 minutes.
On Windows, the NVIDIA driver can let GPU memory overflow into system memory
instead of reporting that it ran out, which makes processing much slower.
When it determines batch sizes automatically, Heretic therefore limits its
memory use on each GPU to what is available after loading the model. With an
explicit batch_size, setting "CUDA - Sysmem Fallback Policy" to
"Prefer No Sysmem Fallback" under "Manage 3D settings" in the NVIDIA Control Panel
has the same effect.
Each trial is evaluated with the modification merged into the model's weights, exactly as in an exported model, so that the scores of a trial are the scores of the model you save. To restore the original weights for the next trial, Heretic keeps a copy of the weights it modifies in system memory, which takes up to about a third of the model's size. With 4-bit quantization, the modification is evaluated as a separate adapter instead, because the exported model is merged without quantization anyway.
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.
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.
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 abliteration6 and norm preservation (MPOA)7. The complete code is in
abliteration.py.
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.
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.jsonHeretic 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 was created by Philipp Emanuel Weidmann, first released in November 2025, and developed together with many community contributors until the original repository was archived on 28 November 2026 (announcement).
The original author took pride in Heretic being written by humans rather than "vibe-coded". By the author's account, all of their own commits up to November 2026 were written entirely by hand, LLM assistance was used only very sparingly after that, and every line of code from other contributors, many of whom used coding agents, was carefully reviewed before it was merged. Design discussions could be long: one pull request accumulated almost 350 human-written comments over more than seven months, and another more than 200. The author credited this approach with giving Heretic a lean, relatively simple codebase that is a pleasure to work on. The original statement, in the author's own words, is in the upstream README.
That statement describes the original project. This continuation is developed with AI assistance, as noted at the top of this file.
The following implementations of abliteration techniques were publicly available when Heretic was first released (November 2025):
- AutoAbliteration
- abliterator.py
- wassname's Abliterator
- ErisForge
- Removing refusals with HF Transformers
- deccp
Note that Heretic was written from scratch, and does not reuse code from any of those projects.
The development of Heretic was informed by:
- The original abliteration paper (Arditi et al. 2024)
- Maxime Labonne's article on abliteration, as well as some details from the model cards of his own abliterated models, such as the use of non-constant ablation weights
- Jim Lai's articles describing "projected abliteration" and "norm-preserving biprojected abliteration"
- Thousands of interactions with members of the community
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}}
}Copyright © 2025-2026 Philipp Emanuel Weidmann (pew@worldwidemann.com) + contributors
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.
By contributing to this project, you agree to release your contributions under the same license.
Footnotes
-
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
quantizationoption tobnb_4bitto enable this. ↩ -
Qwen2.5-7B: Three-Way Abliteration Comparison: "Heretic is the most surgical and most effective." ↩
-
Gemma 4 E4B: 23 Abliteration Variants Compared: "Best overall: heretic." ↩
-
Weidmann 2026. A preprint explaining the technique will be available soon. ↩