Metadata-Version: 2.4
Name: oathburn
Version: 2.2.0rc2
Summary: Automatic abliteration and refusal removal for LLMs. A maintained fork of Heretic, by Oathbreaker.
Keywords: llm,transformer,abliteration,abliterate,uncensored,refusal-removal,heretic,oathbreaker
Author: Philipp Emanuel Weidmann, Oathbreaker (Formacha LLC)
Author-email: Philipp Emanuel Weidmann <pew@worldwidemann.com>, Oathbreaker (Formacha LLC) <support@oathbreaker.ai>
License-Expression: AGPL-3.0-or-later
License-File: LICENSE
License-File: NOTICE
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Environment :: GPU
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Requires-Dist: accelerate~=1.15
Requires-Dist: bitsandbytes~=0.50
Requires-Dist: datasets~=5.0
Requires-Dist: huggingface-hub~=1.33
Requires-Dist: immutabledict~=4.3
Requires-Dist: ipython~=8.39
Requires-Dist: langdetect~=1.0
Requires-Dist: lm-eval[hf]~=0.4
Requires-Dist: numpy~=2.2
Requires-Dist: optuna~=5.0
Requires-Dist: peft~=0.21
Requires-Dist: psutil~=7.2
Requires-Dist: py-cpuinfo~=9.0
Requires-Dist: pydantic-settings~=2.15
Requires-Dist: questionary~=2.1
Requires-Dist: rich~=15.0
Requires-Dist: tomli-w~=1.2
Requires-Dist: torch
Requires-Dist: torchvision
Requires-Dist: tqdm~=4.70
Requires-Dist: transformers[kernels]~=5.18
Maintainer: Oathbreaker (Formacha LLC)
Maintainer-email: Oathbreaker (Formacha LLC) <support@oathbreaker.ai>
Requires-Python: >=3.10
Project-URL: Homepage, https://github.com/Oathbreaker-AI/oathburn
Project-URL: Documentation, https://github.com/Oathbreaker-AI/oathburn#readme
Project-URL: Repository, https://github.com/Oathbreaker-AI/oathburn.git
Project-URL: Issues, https://github.com/Oathbreaker-AI/oathburn/issues
Project-URL: Changelog, https://github.com/Oathbreaker-AI/oathburn/blob/master/CHANGELOG.md
Project-URL: Upstream (Heretic), https://github.com/p-e-w/heretic
Project-URL: Oathbreaker, https://oathbreaker.ai
Description-Content-Type: text/markdown

<p align="center">
  <a href="https://oathbreaker.ai"><img src="https://raw.githubusercontent.com/Oathbreaker-AI/oathburn/master/docs/assets/oathburn-hero.svg" width="100%" alt="Oathburn: remove refusals from open-weight LLMs, no training required. A maintained fork of Heretic, by Oathbreaker."></a>
</p>

<p align="center">
  <a href="https://pypi.org/project/oathburn/"><img src="https://img.shields.io/pypi/v/oathburn?include_prereleases&label=pypi&color=ca0d7b" alt="PyPI version"></a>
  <a href="https://github.com/Oathbreaker-AI/oathburn#hosted-abliterated-models-the-oathbreaker-api"><img src="https://img.shields.io/badge/hosted%20API-oathbreaker.ai-10cbd6" alt="Hosted abliterated models: oathbreaker.ai"></a>
  <a href="https://github.com/Oathbreaker-AI/oathburn/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/Oathbreaker-AI/oathburn/ci.yml?branch=master&label=tests&color=10cbd6" alt="Tests"></a>
  <a href="https://pypi.org/project/oathburn/"><img src="https://img.shields.io/pypi/pyversions/oathburn?color=322237" alt="Python versions"></a>
  <a href="https://github.com/Oathbreaker-AI/oathburn/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0-322237" alt="License: AGPL-3.0"></a>
  <a href="https://github.com/Oathbreaker-AI/oathburn/blob/master/docs/migrating-from-heretic.md"><img src="https://img.shields.io/badge/Heretic-compatible-ca0d7b" alt="Heretic-compatible"></a>
</p>

# Oathburn

### Automatic abliteration and refusal removal for language models

**Oathburn removes refusals and censorship from LLMs automatically**, and can steer
other behavior too: reduce slop, cut sycophancy, shorten responses, and more.
It does this without training, on hardware you already have.

Oathburn is a maintained fork of [Heretic](https://github.com/p-e-w/heretic),
the abliteration tool by Philipp Emanuel Weidmann, which was archived on
28 November 2026. It is maintained by [Oathbreaker](https://oathbreaker.ai).
Oathburn 2.2.0 is Heretic 2.1.0 plus the fixes that were still waiting in
Heretic's pull request queue when it was archived, and it stays compatible with
Heretic's configuration files, plugins and reproducible models.

```sh
pip install -U oathburn
oathburn Qwen/Qwen3-4B-Instruct-2507
```

<p align="center">
  <img src="https://raw.githubusercontent.com/Oathbreaker-AI/oathburn/master/docs/assets/oathburn-terminal.svg" width="100%" alt="Oathburn starting up in a terminal: it loads Qwen3-0.6B, finds 28 layers of modifiable components and determines the best batch size.">
  <br>
  <sub>Real startup output, captured on a CPU-only test machine. One line, an unrelated Hugging Face sign-in warning, is omitted (…). On a GPU, runs are far faster.</sub>
</p>

<p align="center">
  <a href="https://oathbreaker.ai/sign-up?utm_source=github&utm_medium=readme&utm_campaign=oathburn&utm_content=banner"><img src="https://raw.githubusercontent.com/Oathbreaker-AI/oathburn/master/docs/assets/oathburn-hosted-api.svg" width="100%" alt="No GPU? Call abliterated models by API: GLM-5.3, GLM-5.3 Flash, DeepSeek V4.1 Flash and Kimi K3.1 Pro on Oathbreaker's OpenAI-compatible API. Get an API key."></a>
  <br>
  <sub>Don't want to run it yourself? Oathbreaker, the maintainer of Oathburn, serves abliterated models through an OpenAI-compatible API, from $0.40 per million input tokens. <a href="https://github.com/Oathbreaker-AI/oathburn#hosted-abliterated-models-the-oathbreaker-api">See models and prices</a>.</sub>
</p>

-----


## What Oathburn can do

Oathburn modifies any language model you can run on your own hardware.[^1]
Depending on the configuration, it can:

* **Suppress refusals and remove censorship** (the [default](https://github.com/Oathbreaker-AI/oathburn/blob/master/config.default.toml))
* Reduce slop ([`config.noslop.toml`](https://github.com/Oathbreaker-AI/oathburn/blob/master/config.noslop.toml))
* Reduce humor ([`config.nohumor.toml`](https://github.com/Oathbreaker-AI/oathburn/blob/master/config.nohumor.toml))
* Reduce sycophancy ([`config.nosyco.toml`](https://github.com/Oathbreaker-AI/oathburn/blob/master/config.nosyco.toml))
* Alter emotional alignment ([`config.emotions.toml`](https://github.com/Oathbreaker-AI/oathburn/blob/master/config.emotions.toml))
* Shorten responses ([`config.terse.toml`](https://github.com/Oathbreaker-AI/oathburn/blob/master/config.terse.toml))

and many other things, through scorer plugins you can write yourself.

You don't need to understand how language models work internally. Oathburn
finds the parameters by itself: it searches for the modification that removes
the unwanted behavior while changing the model as little as possible.

It supports most dense models, many multimodal models, several mixture-of-experts
(MoE) architectures, and many hybrid models. If a new architecture lays out its
layers differently, you can point Oathburn at the right modules in the
configuration (`layer_module_targets`) instead of waiting for a code change.

[^1]: Oathburn supports on-the-fly 4-bit quantization with bitsandbytes, which
reduces the memory needed to process a model to about what a typical quantized
version of it needs to run, at a slight accuracy cost. Set the `quantization`
option to `bnb_4bit` to enable it.

The community has published [thousands of models](https://huggingface.co/models?other=heretic)
made with Heretic, and independent comparisons rated it favorably against other
abliteration tools on standard benchmarks such as MMLU and GSM8K.[^2][^3]
Oathburn starts from that same code.

[^2]: [Qwen2.5-7B: Three-Way Abliteration Comparison](https://huggingface.co/DreamFast/Qwen-2.5-7b-abliterlitics)
[^3]: [Gemma 4 E4B: 23 Abliteration Variants Compared](https://huggingface.co/DreamFast/Gemma4-e4b-abliterlitics)


## Usage

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

```sh
pip install -U oathburn
oathburn Qwen/Qwen3-4B-Instruct-2507
```

Replace `Qwen/Qwen3-4B-Instruct-2507` with the model you want to process.
**By default, Oathburn removes refusals.** To do something else, pick one of
the configuration files listed above, or write your own. See
[`config.default.toml`](https://github.com/Oathbreaker-AI/oathburn/blob/master/config.default.toml) for all options.

Oathburn reads its configuration from `config.toml` in the working directory,
or from the file named in the `OATHBURN_CONFIG_FILE` environment variable.
Any setting can also be passed on the command line (`oathburn --help`) or as an
environment variable with the `OATHBURN_` prefix.

At the start of a run, Oathburn benchmarks your system to pick the best batch
size. On an RTX 3090 with the default configuration, processing
[Qwen3-4B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507)
takes about 30–40 minutes.

When it finishes, you can save the model, upload it to Hugging Face, chat with
it to see how well it works, run standard benchmarks on it, or any combination
of those.


## Hosted abliterated models: the Oathbreaker API

Oathburn is free and runs on your own hardware, but a run needs a capable GPU,
and the largest open-weight models need far more GPU memory than a workstation
has. If you'd rather just use an abliterated model,
[Oathbreaker](https://oathbreaker.ai/?utm_source=github&utm_medium=readme&utm_campaign=oathburn&utm_content=section),
the team that maintains Oathburn, serves abliterated versions of GLM-5.3,
DeepSeek V4.1 Flash and Kimi K3.1 Pro through an OpenAI-compatible API.
There's nothing to deploy, you pay per token from prepaid credit, and every
request helps fund Oathburn's maintenance.

| Model | Model ID | Input | Cached input | Output |
| --- | --- | ---: | ---: | ---: |
| GLM-5.3 Abliterated | `oathbreaker-glm-5.3` | $3.00 | $0.30 | $4.00 |
| GLM-5.3 Flash Abliterated | `oathbreaker-glm-5.3-flash` | $0.40 | $0.05 | $1.20 |
| DeepSeek V4.1 Flash Abliterated | `oathbreaker-deepseek-v4.1-flash` | $0.40 | $0.05 | $1.20 |
| DeepSeek V4.1 Flash Abliterated, Fast | `oathbreaker-deepseek-v4.1-flash-fast` | $0.50 | $0.05 | $1.50 |
| Kimi K3.1 Pro Abliterated | `oathbreaker-kimi-k3.1-pro` | $4.50 | $0.45 | $9.00 |

<sub>USD per million tokens at standard rates, as of November 2026. Members pay
25% less on every model except Kimi K3.1 Pro. Current prices are on the
[pricing page](https://oathbreaker.ai/pricing?utm_source=github&utm_medium=readme&utm_campaign=oathburn&utm_content=pricing).</sub>

**Get started in a few minutes:**

1. [Create an account](https://oathbreaker.ai/sign-up?utm_source=github&utm_medium=readme&utm_campaign=oathburn&utm_content=section)
   and add credit: pay as you go from $5, or take the Builder plan, $20 a month
   with $21 of credit at member rates.
2. Create an API key in your console.
3. Point any OpenAI-compatible client at `https://oathbreaker.ai/v1`:

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://oathbreaker.ai/v1",
    api_key=os.environ["OATHBREAKER_API_KEY"],
)
response = client.chat.completions.create(
    model="oathbreaker-glm-5.3-flash",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
```

The API uses the Chat Completions format, with streaming and, on supported
models, function calling. Per-model limits are in the [API docs](https://oathbreaker.ai/docs?utm_source=github&utm_medium=readme&utm_campaign=oathburn&utm_content=docs).

**Use it from your coding agent.** Add the hosted MCP server to Claude Code,
Codex, Cursor or OpenCode, and call an abliterated model as a second opinion
next to the model you already use:

```sh
claude mcp add --transport http oathbreaker https://oathbreaker.ai/mcp \
  --header "Authorization: Bearer ${OATHBREAKER_API_KEY}"
```

To use Oathbreaker as the main model in Hermes, OpenCode and other agents, see
the [agent setup guides](https://oathbreaker.ai/agents?utm_source=github&utm_medium=readme&utm_campaign=oathburn&utm_content=agents).
New to abliterated models? Start with the
[guide to what they are and how to use them](https://oathbreaker.ai/guides/abliterated-models?utm_source=github&utm_medium=readme&utm_campaign=oathburn&utm_content=guide).

<p>
  <a href="https://oathbreaker.ai/sign-up?utm_source=github&utm_medium=readme&utm_campaign=oathburn&utm_content=button"><img src="https://img.shields.io/badge/Get%20an%20API%20key-%E2%86%92-ca0d7b?style=for-the-badge" alt="Get an API key"></a>
  <a href="https://oathbreaker.ai/pricing?utm_source=github&utm_medium=readme&utm_campaign=oathburn&utm_content=button"><img src="https://img.shields.io/badge/See%20pricing-%E2%86%92-322237?style=for-the-badge" alt="See pricing"></a>
</p>


## Coming from Heretic

Oathburn is a drop-in replacement for Heretic 2.x:

* **Configuration files** work unchanged. Built-in plugin paths such as
  `heretic.modifiers.ara.ARA` are read as `oathburn.modifiers.ara.ARA`.
* **Environment variables** with the `HERETIC_` prefix, including
  `HERETIC_CONFIG_FILE`, still work. `OATHBURN_` variables take precedence.
* **Third-party plugins** written for Heretic load unchanged, including those
  that `import heretic...`, as long as the original `heretic-llm` package is
  not installed in the same environment.
* **Reproducible Heretic models** can be reproduced with `oathburn --reproduce`,
  and `--collect-reproducibles` collects both Heretic and Oathburn manifests.
* **Study checkpoints** from Heretic runs can be resumed.

See [docs/migrating-from-heretic.md](https://github.com/Oathbreaker-AI/oathburn/blob/master/docs/migrating-from-heretic.md) for details.
Configuration files from Heretic 1.x need the changes in the
[1.x to 2.x migration guide](https://github.com/Oathbreaker-AI/oathburn/blob/master/docs/migration_v1_to_v2.md) first.


## Controlling what Oathburn does with scorer plugins

Oathburn steers model behavior by optimizing one or more scores, which are
computed by scorer plugins. You can write your own scorers to control exactly
what Oathburn does to a model.

Your scorer inherits from the `Scorer` base class in
[`scorer.py`](https://github.com/Oathbreaker-AI/oathburn/blob/master/src/oathburn/scorer.py). The only required method is `get_score`,
and more machinery, such as settings management, is there when you need it.

By default, Oathburn scores models by refusal rate
([`keyword_rate.py`](https://github.com/Oathbreaker-AI/oathburn/blob/master/src/oathburn/scorers/keyword_rate.py)) and KL divergence
from the original model ([`kl_divergence.py`](https://github.com/Oathbreaker-AI/oathburn/blob/master/src/oathburn/scorers/kl_divergence.py)).
More scorers are in the [`scorers` directory](https://github.com/Oathbreaker-AI/oathburn/tree/master/src/oathburn/scorers/); they also
work as examples for your own.

Scorers are configured in the [main configuration file](https://github.com/Oathbreaker-AI/oathburn/blob/master/config.default.toml).
The `scorers` setting chooses which scorers are active and whether each score
is minimized or maximized. Any number of scorers can be co-optimized, and the
same scorer can run several times with different settings.

A plugin is named either by a fully qualified import path
(`fully.qualified.module.MyScorerClass`) or by a file path and class name
(`path/to/plugin.py:MyScorerClass`). You don't have to modify Oathburn itself
to use your own plugins.


## How Oathburn works

<p align="center">
  <img src="https://raw.githubusercontent.com/Oathbreaker-AI/oathburn/master/docs/assets/oathburn-how-it-works.svg" width="100%" alt="How Oathburn works: 1, measure where refusals live using harmless and harmful prompts. 2, modify the model with ARA or abliteration. 3, score refusals and KL divergence. 4, repeat for 100 trials by default, then save, chat with or upload the best result.">
</p>

Oathburn combines a pluggable modifier (interface in
[`modifier.py`](https://github.com/Oathbreaker-AI/oathburn/blob/master/src/oathburn/modifier.py)) with a TPE-based optimizer powered
by [Optuna](https://optuna.org/). The optimizer searches for the modifier
parameters that minimize or maximize the configured scores on the resulting
model.

Two modifiers are included:

* **Arbitrary-Rank Ablation (ARA)**[^4]: the default modifier, developed for
  Heretic. See [the original pull request](https://github.com/p-e-w/heretic/pull/211)
  for an overview and [`ara.py`](https://github.com/Oathbreaker-AI/oathburn/blob/master/src/oathburn/modifiers/ara.py) for the implementation.

* **Directional ablation, also known as abliteration**[^5]: the classic method
  for refusal suppression, with a flexible ablation weight kernel over the
  layers, projected abliteration[^6] and norm preservation (MPOA)[^7]. The code
  is in [`abliteration.py`](https://github.com/Oathbreaker-AI/oathburn/blob/master/src/oathburn/modifiers/abliteration.py).

[^4]: *Weidmann 2026.* Developed for Heretic.
[^5]: *[Arditi et al. 2024](https://arxiv.org/abs/2406.11717)*
[^6]: *[Lai 2025 (1)](https://huggingface.co/blog/grimjim/projected-abliteration)*
[^7]: *[Lai 2025 (2)](https://huggingface.co/blog/grimjim/norm-preserving-biprojected-abliteration)*

The `modifiers` setting switches between them. One modifier is used per run.


## Reproducible models

Oathburn can make *reproducible models*: their repositories hold everything
needed to produce a byte-for-byte identical model on demand, provided the
environment matches the original exactly. PyTorch only guarantees identical
results when the hardware, drivers, operating system and all package versions
are the same, and Oathburn checks all of that for you.

When you upload a model to Hugging Face, Oathburn offers to include a
`reproduce` folder with step-by-step instructions and a machine-readable
manifest, `reproduce.json`. Anyone can then run

```sh
oathburn --reproduce path/to/reproduce.json
```

Oathburn compares their environment with the original, points out mismatches
that could matter, and verifies the weight hashes after export. The multi-hour
search doesn't have to be repeated: reproduction usually takes minutes.

These manifests are only about 9 KB each, so together they form a portable
library of models that can be rebuilt at will. Heretic users know it as the
[Heretic Grimoire](https://huggingface.co/spaces/heretic-org/Heretic-Grimoire).
To keep your own local copy of every public Oathburn and Heretic manifest, run

```sh
oathburn --collect-reproducibles path/to/target/folder/
```

Run it again to update the collection. It only ever adds files, so manifests
stay in your copy even if a model disappears from Hugging Face.


## Model cards

Models uploaded with Oathburn get a model card that names the tool, credits
Heretic, and links to Oathbreaker, the maintainer of Oathburn. Set
`oathbreaker_credit = false` to drop the Oathbreaker link. Uploaded repositories
are tagged `oathburn`.


## Responsible use

Removing refusals removes a safety layer that model makers put in on purpose.
You are responsible for what you do with a modified model: follow the license
of the model you start from and the law where you use it. Never use Oathburn
to produce sexual content involving minors or anything else that is illegal.


## Contributing

Bug reports, model support and pull requests are welcome in the
[issue tracker](https://github.com/Oathbreaker-AI/oathburn/issues). See
[tests/README.md](https://github.com/Oathbreaker-AI/oathburn/blob/master/tests/README.md) for the test suite, which checks that
changes don't silently alter the models Oathburn produces.

The pull requests that were open on Heretic when it was archived are triaged in
[docs/stranded-pull-requests.md](https://github.com/Oathbreaker-AI/oathburn/blob/master/docs/stranded-pull-requests.md). If yours is
listed as deferred, a rebased version is very welcome.


## Prior art and acknowledgments

Oathburn exists because of Heretic and its contributors. Heretic was informed by:

* [The original abliteration paper *(Arditi et al. 2024)*](https://arxiv.org/abs/2406.11717)
* [Maxime Labonne's article on abliteration](https://huggingface.co/blog/mlabonne/abliteration)
  and the model cards of his abliterated models
* Jim Lai's articles on ["projected abliteration"](https://huggingface.co/blog/grimjim/projected-abliteration)
  and ["norm-preserving biprojected abliteration"](https://huggingface.co/blog/grimjim/norm-preserving-biprojected-abliteration)

Earlier abliteration implementations include
[AutoAbliteration](https://huggingface.co/posts/mlabonne/714992455492422),
[abliterator.py](https://github.com/FailSpy/abliterator),
[wassname's Abliterator](https://github.com/wassname/abliterator),
[ErisForge](https://github.com/Tsadoq/ErisForge),
[Removing refusals with HF Transformers](https://github.com/Sumandora/remove-refusals-with-transformers)
and [deccp](https://github.com/AUGMXNT/deccp).


## Citation

If you use Oathburn in research, please cite Heretic, the work it is built on:

```bibtex
@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}}
}
```


## License

Copyright &copy; 2025-2026  Philipp Emanuel Weidmann (<pew@worldwidemann.com>) + contributors<br>
Copyright &copy; 2026  Formacha LLC (Oathbreaker) (<support@oathbreaker.ai>)

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/>.

See [NOTICE](https://github.com/Oathbreaker-AI/oathburn/blob/master/NOTICE) for the origin of this fork and the changes made to it.
Oathburn is not affiliated with or endorsed by Philipp Emanuel Weidmann or the
Heretic project.
