altered-consciousness 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- altered_consciousness-2.2.0/PKG-INFO +238 -0
- altered_consciousness-2.2.0/README.md +187 -0
- altered_consciousness-2.2.0/pyproject.toml +102 -0
- altered_consciousness-2.2.0/pyproject.toml.orig +96 -0
- altered_consciousness-2.2.0/src/altered_consciousness/__init__.py +0 -0
- altered_consciousness-2.2.0/src/altered_consciousness/config.py +648 -0
- altered_consciousness-2.2.0/src/altered_consciousness/evaluator.py +239 -0
- altered_consciousness-2.2.0/src/altered_consciousness/main.py +1563 -0
- altered_consciousness-2.2.0/src/altered_consciousness/model.py +1013 -0
- altered_consciousness-2.2.0/src/altered_consciousness/modifier.py +185 -0
- altered_consciousness-2.2.0/src/altered_consciousness/modifiers/__init__.py +0 -0
- altered_consciousness-2.2.0/src/altered_consciousness/modifiers/abliteration.py +469 -0
- altered_consciousness-2.2.0/src/altered_consciousness/modifiers/ara.py +399 -0
- altered_consciousness-2.2.0/src/altered_consciousness/plugin.py +405 -0
- altered_consciousness-2.2.0/src/altered_consciousness/progress.py +40 -0
- altered_consciousness-2.2.0/src/altered_consciousness/reproduce.py +387 -0
- altered_consciousness-2.2.0/src/altered_consciousness/scorer.py +65 -0
- altered_consciousness-2.2.0/src/altered_consciousness/scorers/__init__.py +0 -0
- altered_consciousness-2.2.0/src/altered_consciousness/scorers/benchmark_score.py +77 -0
- altered_consciousness-2.2.0/src/altered_consciousness/scorers/bert_classifier.py +279 -0
- altered_consciousness-2.2.0/src/altered_consciousness/scorers/keyword_rate.py +161 -0
- altered_consciousness-2.2.0/src/altered_consciousness/scorers/kl_divergence.py +80 -0
- altered_consciousness-2.2.0/src/altered_consciousness/scorers/response_length.py +104 -0
- altered_consciousness-2.2.0/src/altered_consciousness/system.py +478 -0
- altered_consciousness-2.2.0/src/altered_consciousness/utils.py +812 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: altered-consciousness
|
|
3
|
+
Version: 2.2.0
|
|
4
|
+
Summary: Training-free language model modification
|
|
5
|
+
Keywords: llm,transformer,abliteration
|
|
6
|
+
Author: Philipp Emanuel Weidmann
|
|
7
|
+
Author-email: Philipp Emanuel Weidmann <pew@worldwidemann.com>
|
|
8
|
+
License-Expression: AGPL-3.0-or-later
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Environment :: GPU
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
21
|
+
Requires-Dist: accelerate~=1.15
|
|
22
|
+
Requires-Dist: bitsandbytes~=0.50
|
|
23
|
+
Requires-Dist: datasets~=5.0
|
|
24
|
+
Requires-Dist: huggingface-hub~=1.33
|
|
25
|
+
Requires-Dist: immutabledict~=4.3
|
|
26
|
+
Requires-Dist: ipython~=8.39
|
|
27
|
+
Requires-Dist: langdetect~=1.0
|
|
28
|
+
Requires-Dist: lm-eval[hf]~=0.4
|
|
29
|
+
Requires-Dist: numpy~=2.2
|
|
30
|
+
Requires-Dist: optuna~=5.0
|
|
31
|
+
Requires-Dist: peft~=0.21
|
|
32
|
+
Requires-Dist: psutil~=7.2
|
|
33
|
+
Requires-Dist: py-cpuinfo~=9.0
|
|
34
|
+
Requires-Dist: pydantic-settings~=2.15
|
|
35
|
+
Requires-Dist: questionary~=2.1
|
|
36
|
+
Requires-Dist: rich~=15.0
|
|
37
|
+
Requires-Dist: tomli-w~=1.2
|
|
38
|
+
Requires-Dist: torch
|
|
39
|
+
Requires-Dist: torchvision
|
|
40
|
+
Requires-Dist: tqdm~=4.70
|
|
41
|
+
Requires-Dist: transformers[kernels]~=5.18
|
|
42
|
+
Maintainer: Enact Cyber
|
|
43
|
+
Maintainer-email: Enact Cyber <hello@enactcyber.com>
|
|
44
|
+
Requires-Python: >=3.10
|
|
45
|
+
Project-URL: Homepage, https://github.com/getsamsultan/Altered-consciousness
|
|
46
|
+
Project-URL: Documentation, https://github.com/getsamsultan/Altered-consciousness
|
|
47
|
+
Project-URL: Repository, https://github.com/getsamsultan/Altered-consciousness.git
|
|
48
|
+
Project-URL: Issues, https://github.com/getsamsultan/Altered-consciousness/issues
|
|
49
|
+
Project-URL: Upstream, https://github.com/p-e-w/heretic
|
|
50
|
+
Description-Content-Type: text/markdown
|
|
51
|
+
|
|
52
|
+
<div align="center">
|
|
53
|
+
|
|
54
|
+
# Altered Consciousness
|
|
55
|
+
|
|
56
|
+
### Model behaviour testing for teams running their own AI
|
|
57
|
+
|
|
58
|
+
**We report what we observe.**
|
|
59
|
+
|
|
60
|
+
[enactcyber.com](https://enactcyber.com) · [hello@enactcyber.com](mailto:hello@enactcyber.com) · Sydney, Australia
|
|
61
|
+
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
-----
|
|
65
|
+
|
|
66
|
+
> [!NOTE]
|
|
67
|
+
> Altered Consciousness is maintained by Enact Cyber and is based on original work by
|
|
68
|
+
> **Philipp Emanuel Weidmann** and contributors. Enact Cyber did not write the original
|
|
69
|
+
> tool, and all credit for it belongs to its author. See [Credits and citation](#credits-and-citation).
|
|
70
|
+
> Changes made by Enact Cyber are listed under [Changes from the original](#changes-from-the-original).
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
## Why Enact Cyber maintains this tool
|
|
74
|
+
|
|
75
|
+
Enact Cyber is a Sydney-based security assessment practice for Australian businesses.
|
|
76
|
+
Part of our work is **AI agent and private AI hardening** for teams that run their own
|
|
77
|
+
AI agents or local models.
|
|
78
|
+
|
|
79
|
+
If your organisation runs open-weight models, the safety behaviour you rely on lives in
|
|
80
|
+
the model weights, and anyone who can touch those weights can change it. This tool shows
|
|
81
|
+
how cheaply that can be done. It needs no retraining and runs on a single consumer GPU.
|
|
82
|
+
|
|
83
|
+
We use it to:
|
|
84
|
+
|
|
85
|
+
* **Show clients the real risk.** We demonstrate how quickly the safeguards in a model
|
|
86
|
+
they host can be removed or altered, using evidence rather than theory.
|
|
87
|
+
* **Check models before they are deployed.** We test whether a model pulled from a public
|
|
88
|
+
hub has already been modified, and compare its behaviour against the original.
|
|
89
|
+
* **Measure behaviour changes.** We score a model on refusals, verbosity, sycophancy and
|
|
90
|
+
other traits, and record the expected value, the observed value and how it was measured.
|
|
91
|
+
|
|
92
|
+
This repository is published for transparency and for other defenders. If you want a
|
|
93
|
+
hands-on assessment of your own AI deployment, [book a 30-minute call](https://enactcyber.com).
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## What it does
|
|
97
|
+
|
|
98
|
+
Altered Consciousness modifies the behaviour of a language model without training it.
|
|
99
|
+
It compares the model's internal activations on contrasting sets of example prompts.
|
|
100
|
+
It then uses an Optuna (TPE) optimiser to search for weight changes that move a set of
|
|
101
|
+
configurable scores, while keeping the model as close to the original as possible.
|
|
102
|
+
|
|
103
|
+
Depending on the configuration, it can:
|
|
104
|
+
|
|
105
|
+
* Suppress refusals (the [default configuration](/config.default.toml))
|
|
106
|
+
* Reduce slop ([`config.noslop.toml`](/config.noslop.toml))
|
|
107
|
+
* Reduce humour ([`config.nohumor.toml`](/config.nohumor.toml))
|
|
108
|
+
* Reduce sycophancy ([`config.nosyco.toml`](/config.nosyco.toml))
|
|
109
|
+
* Alter emotional alignment ([`config.emotions.toml`](/config.emotions.toml))
|
|
110
|
+
* Shorten responses ([`config.terse.toml`](/config.terse.toml))
|
|
111
|
+
|
|
112
|
+
It supports most dense models, many multimodal models, several MoE architectures and
|
|
113
|
+
many hybrid models. With 4-bit quantisation (`quantization = "bnb_4bit"`), the VRAM it
|
|
114
|
+
needs is roughly what you would need to run a quantised copy of the model.
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
## Usage
|
|
118
|
+
|
|
119
|
+
You need Python 3.10+ and PyTorch 2.6+ installed for your hardware. Then run:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
pip install -U git+https://github.com/getsamsultan/Altered-consciousness.git
|
|
123
|
+
altered-consciousness Qwen/Qwen3-4B-Instruct-2507
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Replace the model name with the model you want to test. The tool reads `config.toml`
|
|
127
|
+
from the working directory, or from the path in the `ALTERED_CONSCIOUSNESS_CONFIG_FILE`
|
|
128
|
+
environment variable. Any setting can also be passed as an environment variable with the
|
|
129
|
+
`ALTERED_CONSCIOUSNESS_` prefix. See [`config.default.toml`](/config.default.toml) for
|
|
130
|
+
every option.
|
|
131
|
+
|
|
132
|
+
> [!IMPORTANT]
|
|
133
|
+
> Configuration files written for 1.x releases do not work with 2.x. See the
|
|
134
|
+
> [migration guide](/docs/migration_v1_to_v2.md). Plugin paths in older configuration
|
|
135
|
+
> files must also be updated to the new package name (`altered_consciousness.…`).
|
|
136
|
+
|
|
137
|
+
The tool benchmarks your hardware at startup to choose a batch size. On an RTX 3090,
|
|
138
|
+
processing Qwen3-4B-Instruct-2507 with the default configuration takes about 30 to 40
|
|
139
|
+
minutes. When it finishes, you can save the model, upload it, chat with it, run standard
|
|
140
|
+
benchmarks on it, or any combination of these.
|
|
141
|
+
|
|
142
|
+
**Only process models you are licensed to modify, and only on systems you are authorised
|
|
143
|
+
to test.**
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
## Scorers
|
|
147
|
+
|
|
148
|
+
The tool optimises one or more scores, each produced by a scorer plugin. The defaults are
|
|
149
|
+
refusal rate ([`keyword_rate.py`](/src/altered_consciousness/scorers/keyword_rate.py)) and
|
|
150
|
+
KL divergence from the original model
|
|
151
|
+
([`kl_divergence.py`](/src/altered_consciousness/scorers/kl_divergence.py)). More scorers
|
|
152
|
+
are in [`src/altered_consciousness/scorers/`](/src/altered_consciousness/scorers/).
|
|
153
|
+
|
|
154
|
+
To write your own, subclass `Scorer` in [`scorer.py`](/src/altered_consciousness/scorer.py)
|
|
155
|
+
and implement `get_score`. Enable it with the `scorers` setting, using either an import
|
|
156
|
+
path (`my.module.MyScorer`) or a file path (`path/to/plugin.py:MyScorer`). You can run
|
|
157
|
+
several scorers at once, each set to be minimised or maximised.
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
## Modifiers
|
|
161
|
+
|
|
162
|
+
The modifier decides how weights are changed. Choose one with the `modifiers` setting.
|
|
163
|
+
|
|
164
|
+
* **Arbitrary-Rank Ablation (ARA)** is the default, developed by the original author.
|
|
165
|
+
See [`ara.py`](/src/altered_consciousness/modifiers/ara.py).
|
|
166
|
+
* **Directional ablation ("abliteration")**, with projected abliteration and
|
|
167
|
+
norm preservation (MPOA), is in
|
|
168
|
+
[`abliteration.py`](/src/altered_consciousness/modifiers/abliteration.py).
|
|
169
|
+
Background: [Arditi et al. 2024](https://arxiv.org/abs/2406.11717).
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
## Reproducibility
|
|
173
|
+
|
|
174
|
+
When you upload a processed model, the tool can add a `reproduce` folder containing a
|
|
175
|
+
small `reproduce.json` manifest. Anyone with the same environment can then rebuild the
|
|
176
|
+
model in minutes, without repeating the optimisation:
|
|
177
|
+
|
|
178
|
+
```sh
|
|
179
|
+
altered-consciousness --reproduce path/to/reproduce.json
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The tool checks your environment against the original and verifies weight hashes
|
|
183
|
+
afterwards. To take a local, append-only copy of the public library of reproducible
|
|
184
|
+
models on Hugging Face, run:
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
altered-consciousness --collect-reproducibles path/to/folder/
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
For assessments, this means a finding about a modified model can be reproduced and
|
|
191
|
+
checked by someone else.
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
## Changes from the original
|
|
195
|
+
|
|
196
|
+
| Date | Change |
|
|
197
|
+
|------|--------|
|
|
198
|
+
| 2026-12-01 | Forked from the original repository at its archived state. Renamed to Altered Consciousness: package `altered_consciousness`, command `altered-consciousness`, environment prefix `ALTERED_CONSCIOUSNESS_`, Hugging Face upload tag `altered-consciousness`. README rewritten for Enact Cyber. No changes to how models are processed. |
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
## Credits and citation
|
|
202
|
+
|
|
203
|
+
This tool is based on **Heretic**, created by
|
|
204
|
+
[Philipp Emanuel Weidmann](https://github.com/p-e-w) with community contributors
|
|
205
|
+
([original repository](https://github.com/p-e-w/heretic)). The original work drew on
|
|
206
|
+
research by Arditi et al., Maxime Labonne and Jim Lai.
|
|
207
|
+
|
|
208
|
+
If you use this tool in research, please cite the original work:
|
|
209
|
+
|
|
210
|
+
```bibtex
|
|
211
|
+
@misc{heretic,
|
|
212
|
+
author = {Weidmann, Philipp Emanuel},
|
|
213
|
+
title = {Heretic: Training-free language model modification},
|
|
214
|
+
year = {2025},
|
|
215
|
+
publisher = {GitHub},
|
|
216
|
+
journal = {GitHub repository},
|
|
217
|
+
howpublished = {\url{https://github.com/p-e-w/heretic}}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
## Licence
|
|
223
|
+
|
|
224
|
+
Copyright © 2025-2026 Philipp Emanuel Weidmann (<pew@worldwidemann.com>) + contributors.
|
|
225
|
+
Modifications © 2026 Enact Cyber (ABN 89 018 036 700).
|
|
226
|
+
|
|
227
|
+
This program is free software: you can redistribute it and/or modify it under the terms
|
|
228
|
+
of the GNU Affero General Public License as published by the Free Software Foundation,
|
|
229
|
+
either version 3 of the License, or (at your option) any later version.
|
|
230
|
+
|
|
231
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
232
|
+
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
233
|
+
See the GNU Affero General Public License for more details.
|
|
234
|
+
|
|
235
|
+
You should have received a copy of the GNU Affero General Public License along with this
|
|
236
|
+
program. If not, see <https://www.gnu.org/licenses/>.
|
|
237
|
+
|
|
238
|
+
**Contributions to this project are released under the same licence.**
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Altered Consciousness
|
|
4
|
+
|
|
5
|
+
### Model behaviour testing for teams running their own AI
|
|
6
|
+
|
|
7
|
+
**We report what we observe.**
|
|
8
|
+
|
|
9
|
+
[enactcyber.com](https://enactcyber.com) · [hello@enactcyber.com](mailto:hello@enactcyber.com) · Sydney, Australia
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
-----
|
|
14
|
+
|
|
15
|
+
> [!NOTE]
|
|
16
|
+
> Altered Consciousness is maintained by Enact Cyber and is based on original work by
|
|
17
|
+
> **Philipp Emanuel Weidmann** and contributors. Enact Cyber did not write the original
|
|
18
|
+
> tool, and all credit for it belongs to its author. See [Credits and citation](#credits-and-citation).
|
|
19
|
+
> Changes made by Enact Cyber are listed under [Changes from the original](#changes-from-the-original).
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## Why Enact Cyber maintains this tool
|
|
23
|
+
|
|
24
|
+
Enact Cyber is a Sydney-based security assessment practice for Australian businesses.
|
|
25
|
+
Part of our work is **AI agent and private AI hardening** for teams that run their own
|
|
26
|
+
AI agents or local models.
|
|
27
|
+
|
|
28
|
+
If your organisation runs open-weight models, the safety behaviour you rely on lives in
|
|
29
|
+
the model weights, and anyone who can touch those weights can change it. This tool shows
|
|
30
|
+
how cheaply that can be done. It needs no retraining and runs on a single consumer GPU.
|
|
31
|
+
|
|
32
|
+
We use it to:
|
|
33
|
+
|
|
34
|
+
* **Show clients the real risk.** We demonstrate how quickly the safeguards in a model
|
|
35
|
+
they host can be removed or altered, using evidence rather than theory.
|
|
36
|
+
* **Check models before they are deployed.** We test whether a model pulled from a public
|
|
37
|
+
hub has already been modified, and compare its behaviour against the original.
|
|
38
|
+
* **Measure behaviour changes.** We score a model on refusals, verbosity, sycophancy and
|
|
39
|
+
other traits, and record the expected value, the observed value and how it was measured.
|
|
40
|
+
|
|
41
|
+
This repository is published for transparency and for other defenders. If you want a
|
|
42
|
+
hands-on assessment of your own AI deployment, [book a 30-minute call](https://enactcyber.com).
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## What it does
|
|
46
|
+
|
|
47
|
+
Altered Consciousness modifies the behaviour of a language model without training it.
|
|
48
|
+
It compares the model's internal activations on contrasting sets of example prompts.
|
|
49
|
+
It then uses an Optuna (TPE) optimiser to search for weight changes that move a set of
|
|
50
|
+
configurable scores, while keeping the model as close to the original as possible.
|
|
51
|
+
|
|
52
|
+
Depending on the configuration, it can:
|
|
53
|
+
|
|
54
|
+
* Suppress refusals (the [default configuration](/config.default.toml))
|
|
55
|
+
* Reduce slop ([`config.noslop.toml`](/config.noslop.toml))
|
|
56
|
+
* Reduce humour ([`config.nohumor.toml`](/config.nohumor.toml))
|
|
57
|
+
* Reduce sycophancy ([`config.nosyco.toml`](/config.nosyco.toml))
|
|
58
|
+
* Alter emotional alignment ([`config.emotions.toml`](/config.emotions.toml))
|
|
59
|
+
* Shorten responses ([`config.terse.toml`](/config.terse.toml))
|
|
60
|
+
|
|
61
|
+
It supports most dense models, many multimodal models, several MoE architectures and
|
|
62
|
+
many hybrid models. With 4-bit quantisation (`quantization = "bnb_4bit"`), the VRAM it
|
|
63
|
+
needs is roughly what you would need to run a quantised copy of the model.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
You need Python 3.10+ and PyTorch 2.6+ installed for your hardware. Then run:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
pip install -U git+https://github.com/getsamsultan/Altered-consciousness.git
|
|
72
|
+
altered-consciousness Qwen/Qwen3-4B-Instruct-2507
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Replace the model name with the model you want to test. The tool reads `config.toml`
|
|
76
|
+
from the working directory, or from the path in the `ALTERED_CONSCIOUSNESS_CONFIG_FILE`
|
|
77
|
+
environment variable. Any setting can also be passed as an environment variable with the
|
|
78
|
+
`ALTERED_CONSCIOUSNESS_` prefix. See [`config.default.toml`](/config.default.toml) for
|
|
79
|
+
every option.
|
|
80
|
+
|
|
81
|
+
> [!IMPORTANT]
|
|
82
|
+
> Configuration files written for 1.x releases do not work with 2.x. See the
|
|
83
|
+
> [migration guide](/docs/migration_v1_to_v2.md). Plugin paths in older configuration
|
|
84
|
+
> files must also be updated to the new package name (`altered_consciousness.…`).
|
|
85
|
+
|
|
86
|
+
The tool benchmarks your hardware at startup to choose a batch size. On an RTX 3090,
|
|
87
|
+
processing Qwen3-4B-Instruct-2507 with the default configuration takes about 30 to 40
|
|
88
|
+
minutes. When it finishes, you can save the model, upload it, chat with it, run standard
|
|
89
|
+
benchmarks on it, or any combination of these.
|
|
90
|
+
|
|
91
|
+
**Only process models you are licensed to modify, and only on systems you are authorised
|
|
92
|
+
to test.**
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
## Scorers
|
|
96
|
+
|
|
97
|
+
The tool optimises one or more scores, each produced by a scorer plugin. The defaults are
|
|
98
|
+
refusal rate ([`keyword_rate.py`](/src/altered_consciousness/scorers/keyword_rate.py)) and
|
|
99
|
+
KL divergence from the original model
|
|
100
|
+
([`kl_divergence.py`](/src/altered_consciousness/scorers/kl_divergence.py)). More scorers
|
|
101
|
+
are in [`src/altered_consciousness/scorers/`](/src/altered_consciousness/scorers/).
|
|
102
|
+
|
|
103
|
+
To write your own, subclass `Scorer` in [`scorer.py`](/src/altered_consciousness/scorer.py)
|
|
104
|
+
and implement `get_score`. Enable it with the `scorers` setting, using either an import
|
|
105
|
+
path (`my.module.MyScorer`) or a file path (`path/to/plugin.py:MyScorer`). You can run
|
|
106
|
+
several scorers at once, each set to be minimised or maximised.
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
## Modifiers
|
|
110
|
+
|
|
111
|
+
The modifier decides how weights are changed. Choose one with the `modifiers` setting.
|
|
112
|
+
|
|
113
|
+
* **Arbitrary-Rank Ablation (ARA)** is the default, developed by the original author.
|
|
114
|
+
See [`ara.py`](/src/altered_consciousness/modifiers/ara.py).
|
|
115
|
+
* **Directional ablation ("abliteration")**, with projected abliteration and
|
|
116
|
+
norm preservation (MPOA), is in
|
|
117
|
+
[`abliteration.py`](/src/altered_consciousness/modifiers/abliteration.py).
|
|
118
|
+
Background: [Arditi et al. 2024](https://arxiv.org/abs/2406.11717).
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
## Reproducibility
|
|
122
|
+
|
|
123
|
+
When you upload a processed model, the tool can add a `reproduce` folder containing a
|
|
124
|
+
small `reproduce.json` manifest. Anyone with the same environment can then rebuild the
|
|
125
|
+
model in minutes, without repeating the optimisation:
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
altered-consciousness --reproduce path/to/reproduce.json
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The tool checks your environment against the original and verifies weight hashes
|
|
132
|
+
afterwards. To take a local, append-only copy of the public library of reproducible
|
|
133
|
+
models on Hugging Face, run:
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
altered-consciousness --collect-reproducibles path/to/folder/
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
For assessments, this means a finding about a modified model can be reproduced and
|
|
140
|
+
checked by someone else.
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
## Changes from the original
|
|
144
|
+
|
|
145
|
+
| Date | Change |
|
|
146
|
+
|------|--------|
|
|
147
|
+
| 2026-12-01 | Forked from the original repository at its archived state. Renamed to Altered Consciousness: package `altered_consciousness`, command `altered-consciousness`, environment prefix `ALTERED_CONSCIOUSNESS_`, Hugging Face upload tag `altered-consciousness`. README rewritten for Enact Cyber. No changes to how models are processed. |
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
## Credits and citation
|
|
151
|
+
|
|
152
|
+
This tool is based on **Heretic**, created by
|
|
153
|
+
[Philipp Emanuel Weidmann](https://github.com/p-e-w) with community contributors
|
|
154
|
+
([original repository](https://github.com/p-e-w/heretic)). The original work drew on
|
|
155
|
+
research by Arditi et al., Maxime Labonne and Jim Lai.
|
|
156
|
+
|
|
157
|
+
If you use this tool in research, please cite the original work:
|
|
158
|
+
|
|
159
|
+
```bibtex
|
|
160
|
+
@misc{heretic,
|
|
161
|
+
author = {Weidmann, Philipp Emanuel},
|
|
162
|
+
title = {Heretic: Training-free language model modification},
|
|
163
|
+
year = {2025},
|
|
164
|
+
publisher = {GitHub},
|
|
165
|
+
journal = {GitHub repository},
|
|
166
|
+
howpublished = {\url{https://github.com/p-e-w/heretic}}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
## Licence
|
|
172
|
+
|
|
173
|
+
Copyright © 2025-2026 Philipp Emanuel Weidmann (<pew@worldwidemann.com>) + contributors.
|
|
174
|
+
Modifications © 2026 Enact Cyber (ABN 89 018 036 700).
|
|
175
|
+
|
|
176
|
+
This program is free software: you can redistribute it and/or modify it under the terms
|
|
177
|
+
of the GNU Affero General Public License as published by the Free Software Foundation,
|
|
178
|
+
either version 3 of the License, or (at your option) any later version.
|
|
179
|
+
|
|
180
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
181
|
+
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
182
|
+
See the GNU Affero General Public License for more details.
|
|
183
|
+
|
|
184
|
+
You should have received a copy of the GNU Affero General Public License along with this
|
|
185
|
+
program. If not, see <https://www.gnu.org/licenses/>.
|
|
186
|
+
|
|
187
|
+
**Contributions to this project are released under the same licence.**
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "altered-consciousness"
|
|
3
|
+
version = "2.2.0"
|
|
4
|
+
description = "Training-free language model modification"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "AGPL-3.0-or-later"
|
|
7
|
+
requires-python = ">=3.10"
|
|
8
|
+
keywords = [
|
|
9
|
+
"llm",
|
|
10
|
+
"transformer",
|
|
11
|
+
"abliteration",
|
|
12
|
+
]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 5 - Production/Stable",
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Environment :: GPU",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
25
|
+
"Programming Language :: Python :: 3.15",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"accelerate~=1.15",
|
|
29
|
+
"bitsandbytes~=0.50",
|
|
30
|
+
"datasets~=5.0",
|
|
31
|
+
"huggingface-hub~=1.33",
|
|
32
|
+
"immutabledict~=4.3",
|
|
33
|
+
"ipython~=8.39",
|
|
34
|
+
"langdetect~=1.0",
|
|
35
|
+
"lm-eval[hf]~=0.4",
|
|
36
|
+
"numpy~=2.2",
|
|
37
|
+
"optuna~=5.0",
|
|
38
|
+
"peft~=0.21",
|
|
39
|
+
"psutil~=7.2",
|
|
40
|
+
"py-cpuinfo~=9.0",
|
|
41
|
+
"pydantic-settings~=2.15",
|
|
42
|
+
"questionary~=2.1",
|
|
43
|
+
"rich~=15.0",
|
|
44
|
+
"tomli-w~=1.2",
|
|
45
|
+
"torch",
|
|
46
|
+
"torchvision",
|
|
47
|
+
"tqdm~=4.70",
|
|
48
|
+
"transformers[kernels]~=5.18",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[[project.authors]]
|
|
52
|
+
name = "Philipp Emanuel Weidmann"
|
|
53
|
+
email = "pew@worldwidemann.com"
|
|
54
|
+
|
|
55
|
+
[[project.maintainers]]
|
|
56
|
+
name = "Enact Cyber"
|
|
57
|
+
email = "hello@enactcyber.com"
|
|
58
|
+
|
|
59
|
+
[project.urls]
|
|
60
|
+
Homepage = "https://github.com/getsamsultan/Altered-consciousness"
|
|
61
|
+
Documentation = "https://github.com/getsamsultan/Altered-consciousness"
|
|
62
|
+
Repository = "https://github.com/getsamsultan/Altered-consciousness.git"
|
|
63
|
+
Issues = "https://github.com/getsamsultan/Altered-consciousness/issues"
|
|
64
|
+
Upstream = "https://github.com/p-e-w/heretic"
|
|
65
|
+
|
|
66
|
+
[project.scripts]
|
|
67
|
+
altered-consciousness = "altered_consciousness.main:main"
|
|
68
|
+
|
|
69
|
+
[dependency-groups]
|
|
70
|
+
dev = [
|
|
71
|
+
"ruff>=0.16.9",
|
|
72
|
+
"ty>=0.0.84",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[build-system]
|
|
76
|
+
requires = ["uv_build>=0.12.21,<0.13.0"]
|
|
77
|
+
build-backend = "uv_build"
|
|
78
|
+
|
|
79
|
+
[tool.ruff.lint]
|
|
80
|
+
ignore = [
|
|
81
|
+
"B023",
|
|
82
|
+
"BLE001",
|
|
83
|
+
"TRY002",
|
|
84
|
+
"SIM117",
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
[tool.uv]
|
|
88
|
+
exclude-newer = "7 days"
|
|
89
|
+
|
|
90
|
+
[tool.uv.sources.torch]
|
|
91
|
+
index = "pytorch"
|
|
92
|
+
|
|
93
|
+
[tool.uv.sources.torchvision]
|
|
94
|
+
index = "pytorch"
|
|
95
|
+
|
|
96
|
+
[[tool.uv.index]]
|
|
97
|
+
name = "pytorch"
|
|
98
|
+
url = "https://download.pytorch.org/whl/cpu"
|
|
99
|
+
explicit = true
|
|
100
|
+
|
|
101
|
+
[tool.uv.build-backend]
|
|
102
|
+
module-name = "altered_consciousness"
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "altered-consciousness"
|
|
3
|
+
version = "2.2.0"
|
|
4
|
+
description = "Training-free language model modification"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "AGPL-3.0-or-later"
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "Philipp Emanuel Weidmann", email = "pew@worldwidemann.com" }
|
|
9
|
+
]
|
|
10
|
+
maintainers = [
|
|
11
|
+
{ name = "Enact Cyber", email = "hello@enactcyber.com" }
|
|
12
|
+
]
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
keywords = ["llm", "transformer", "abliteration"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 5 - Production/Stable",
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Environment :: GPU",
|
|
19
|
+
"Intended Audience :: Science/Research",
|
|
20
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Programming Language :: Python :: 3.14",
|
|
27
|
+
"Programming Language :: Python :: 3.15",
|
|
28
|
+
]
|
|
29
|
+
dependencies = [
|
|
30
|
+
"accelerate~=1.15",
|
|
31
|
+
"bitsandbytes~=0.50",
|
|
32
|
+
"datasets~=5.0",
|
|
33
|
+
"huggingface-hub~=1.33",
|
|
34
|
+
"immutabledict~=4.3",
|
|
35
|
+
"ipython~=8.39",
|
|
36
|
+
"langdetect~=1.0",
|
|
37
|
+
"lm-eval[hf]~=0.4",
|
|
38
|
+
"numpy~=2.2",
|
|
39
|
+
"optuna~=5.0",
|
|
40
|
+
"peft~=0.21",
|
|
41
|
+
"psutil~=7.2",
|
|
42
|
+
"py-cpuinfo~=9.0",
|
|
43
|
+
"pydantic-settings~=2.15",
|
|
44
|
+
"questionary~=2.1",
|
|
45
|
+
"rich~=15.0",
|
|
46
|
+
"tomli-w~=1.2",
|
|
47
|
+
"torch", # version deliberately unspecified
|
|
48
|
+
"torchvision", # version deliberately unspecified
|
|
49
|
+
"tqdm~=4.70",
|
|
50
|
+
"transformers[kernels]~=5.18",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[dependency-groups]
|
|
54
|
+
dev = [
|
|
55
|
+
"ruff>=0.16.9",
|
|
56
|
+
"ty>=0.0.84",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
[project.urls]
|
|
60
|
+
Homepage = "https://github.com/getsamsultan/Altered-consciousness"
|
|
61
|
+
Documentation = "https://github.com/getsamsultan/Altered-consciousness"
|
|
62
|
+
Repository = "https://github.com/getsamsultan/Altered-consciousness.git"
|
|
63
|
+
Issues = "https://github.com/getsamsultan/Altered-consciousness/issues"
|
|
64
|
+
Upstream = "https://github.com/p-e-w/heretic"
|
|
65
|
+
|
|
66
|
+
[project.scripts]
|
|
67
|
+
altered-consciousness = "altered_consciousness.main:main"
|
|
68
|
+
|
|
69
|
+
[build-system]
|
|
70
|
+
requires = ["uv_build>=0.12.21,<0.13.0"]
|
|
71
|
+
build-backend = "uv_build"
|
|
72
|
+
|
|
73
|
+
[tool.ruff.lint]
|
|
74
|
+
ignore = [
|
|
75
|
+
"B023", # "Function definition does not bind loop variable"
|
|
76
|
+
"BLE001", # "Do not catch blind exception"
|
|
77
|
+
"TRY002", # "Create your own exception"
|
|
78
|
+
"SIM117", # "Use a single `with` statement with multiple contexts instead of nested `with` statements"
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
[tool.uv]
|
|
82
|
+
exclude-newer = "7 days"
|
|
83
|
+
|
|
84
|
+
[tool.uv.sources]
|
|
85
|
+
torch = { index = "pytorch" }
|
|
86
|
+
torchvision = { index = "pytorch" }
|
|
87
|
+
|
|
88
|
+
[[tool.uv.index]]
|
|
89
|
+
# Default to CPU wheels for PyTorch to avoid issues in CI.
|
|
90
|
+
# Can be overridden by passing `--index pytorch=<url>` to uv.
|
|
91
|
+
name = "pytorch"
|
|
92
|
+
url = "https://download.pytorch.org/whl/cpu"
|
|
93
|
+
explicit = true
|
|
94
|
+
|
|
95
|
+
[tool.uv.build-backend]
|
|
96
|
+
module-name = "altered_consciousness"
|
|
File without changes
|