Abliteration HandbookField guide
Methods

Projected & norm-preserving pipeline (llm-abliteration)

Manual implementation of Jim Lai refinements via jim-plus/llm-abliteration.

1 min read 5 examples Source-linked

In this chapter
Interactive companion

Explore the geometry

Use the visual controls alongside the complete source chapter.

Manual implementation of Jim Lai refinements via jim-plus/llm-abliteration.

Full command chain#

bash
git clone https://github.com/jim-plus/llm-abliteration.git tools/llm-abliteration
cd tools/llm-abliteration
pip install -r requirements.txt bitsandbytes

1. Measure (optionally 4-bit)#

bash
python measure.py -m <model_path> -o directions.pt \
  --data-harmful ./data/harmful.txt \
  --data-harmless ./data/harmless.txt \
  --quant 4bit \
  --projected

--projected computes refusal direction orthogonal to harmless centroid per layer.

2. Analyze layer geometry#

bash
python analyze.py directions.pt -c

Select layers where refusal signal peaks (typically 45%–75% depth).

3. Configure ablation YAML#

Edit repo example — set:

  • layers: [L_start, ..., L_end]
  • alpha: 0.5 starting partial strength
  • targets: [down_proj, o_proj] as supported

4. Sharded ablate#

bash
python sharded_ablate.py abliteration_config.yaml \
  --projected --normpreserve

--normpreserve keeps row norms of each weight matrix.

5. Compare#

bash
python compare.py -a <base> -b <abliterated>
python chat.py -m <abliterated>

When vs Heretic#

Criterionllm-abliteration manualHeretic
Optuna kernel searchManual layer/αAutomatic
MoE expertsManual loopBuilt-in
ReproducibilityFull YAML controlconfig.toml
Speed to checkpointSlowerFaster

Use manual pipeline when Heretic unsupported architecture or you need paper-exact projected+normpreserve without Optuna.

→ ../techniques/projected-norm-preserving-abliteration.md

Trace this chapter to its source.

The complete Markdown remains the editable source. This page adds navigation, typography, and a visual companion.

methods/projected-llm-abliteration.md
Inspect the source fingerprintSHA-256 9cf8ced034218575dec80e76ad0606a01de9341a57e8690e55e940681aa07202Source commit 6fba7436a5914cad7c8f0835a14b480a29dac263