Heretic

From akillness/jeo-skills · View interactive version

Heretic is an AI agent skill from the GitHub repository akillness/jeo-skills. Runs directional ablation and refusal-direction analysis for open-weight models the user may modify; use to reduce benign over-refusal or measure refusal/KL trade-offs, not for training.

How to use this skill

Skill file

heretic — Automatic Abliteration & Refusal-Direction Interpretability

Keyword: heretic · abliterate · decensor a model · remove refusals · refusal direction · plot residuals

Responsible use. Heretic is AGPL-3.0 software for research and for customizing models **you have

the right to modify**. Respect each base model's license and every platform's Terms of Service when

downloading, modifying, uploading, or serving weights. Abliteration lowers a model's refusal rate on

all topics, including genuinely harmful ones — do not use it to produce a model for illegal content

(e.g. CSAM, weapons-of-mass-destruction uplift, targeted harassment) or to evade safety controls you

are contractually bound by. Legitimate uses include interpretability/alignment research, red-teaming,

reducing benign over-refusal, and running uncensored models on your own hardware for lawful work.

heretic packages the p-e-w/heretic tool (AGPL-3.0) as an installable

jeo-skills plugin. Heretic implements a parametrized variant of directional ablation (abliteration,

after Arditi et al. 2024): it computes a per-layer "refusal

direction" as the difference-of-means between first-token residuals for harmful and harmless prompts,

then orthogonalizes the attention out-projection and MLP down-projection matrices against it — inhibiting

refusals without any fine-tuning or post-training. A TPE optimizer (Optuna) searches the ablation

kernel to minimize refusals while keeping KL-divergence from the original model low, so the process is

fully automatic and needs no configuration.

This skill is routing-first: pick the smallest workable mode for the request, keep the responsible-use

guardrails above in view, and route web-based discovery/research through scrapling.


When to use / not use

Use heretic when the user wants to:

Do NOT route here (answer directly or elsewhere):


Modes (pick the smallest that satisfies the request)

| Mode | Trigger | Command / action |

| :--- | :--- | :--- |

| decensor (default) | "abliterate / decensor <model>" | heretic <model> — fully automatic; then choose save / upload / chat / evaluate |

| configure | "fit in 16GB", "more trials", "less brain damage" | edit config.*.toml or pass flags (--quantization bnb_4bit, --n-trials, --kl-divergence-target) |

| evaluate | "how censored is it / did it work" | heretic --model <orig> --evaluate-model <candidate> → refusals + KL |

| research | "plot residuals", "refusal geometry" | pip install -U 'heretic-llm[research]'; --plot-residuals / --print-residual-geometry |

| discover (scrapling) | "find a base model / existing heretic model / benchmarks" | route web extraction through scrapling (see below) |

Start narrow: an evaluate or discover request must not kick off a full multi-hour decensor run.

decensor (default)

pip install -U heretic-llm          # or: uv run heretic  (pins uv.lock for reproducibility)
heretic Qwen/Qwen3-4B-Instruct-2507 # replace with any model you have the right to modify

The run is fully automatic: Heretic benchmarks the hardware to pick a batch size, computes refusal

directions, then runs the Optuna TPE optimizer (default n_trials = 200, n_startup_trials = 60)

to co-minimize (a) refusals on harmful prompts and (b) KL-divergence from the original on harmless

prompts. When it finishes you are offered: save, upload to Hugging Face, chat (test), and

run benchmarks — any combination. Checkpoints land in checkpoints/ so a run can resume.

configure

Fully automatic already works; reach for config only for hardware/quality control. Common knobs

(see config.default.toml, or the bundled presets config.nohumor.toml / config.noslop.toml):

Run heretic --help for all CLI flags; any TOML key is also a --kebab-case flag.

evaluate

Reproduce the metric table (refusals for harmful prompts / KL-divergence for harmless prompts) without

re-abliterating — e.g. to compare your output against an existing community model:

heretic --model google/gemma-3-12b-it --evaluate-model p-e-w/gemma-3-12b-it-heretic

Report both numbers: lower refusals = less censored; lower KL = less capability damage. A good

abliteration matches others' refusal suppression at a much lower KL (Heretic's headline result).

research (interpretability)

pip install -U 'heretic-llm[research]'
heretic <model> --print-residual-geometry   # metrics table: cosine sims, norms, silhouette
heretic <model> --plot-residuals            # PaCMAP projection PNG per layer + animated GIF

--print-residual-geometry prints per-layer S(g,b), S(g*,b*), refusal-direction norms and the

silhouette coefficient of the harmful/harmless clusters (g=good/harmless mean, b=bad/harmful mean,

*=geometric median, r = b − g = refusal direction). --plot-residuals runs a PaCMAP projection

(CPU-heavy — an hour+ for large models) and renders a layer-by-layer residual animation.

discover (route through `scrapling`)

For anything requiring the live web — locating a base model, checking whether a heretic/abliterated

version already exists, or pulling benchmark/prior-art numbers — route to the scrapling skill and

pick its lightest workable mode. See references/research-and-scrapling.md.


How Heretic works (one screen)

  1. Refusal directions. For each layer, mean first-token residual for harmful prompts minus that for

harmless prompts (r = b − g). A float direction_index interpolates between adjacent layers'

directions, unlocking directions no single layer provides.

  1. Ablation. Orthogonalize attention out-projection and MLP down-projection against r. A flexible

per-component weight kernel (max_weight, max_weight_position, min_weight,

min_weight_distance) shapes how strongly each layer is ablated.

  1. Optimize. Optuna TPE searches kernel + direction params to minimize refusals and KL-divergence

simultaneously. Attention and MLP get separate parameters (MLP interventions are more damaging).

Detail: references/abliteration-and-optimization.md ·

CLI/config: references/cli-and-config.md.


Workflow

  1. Classify the request → mode (decensor / configure / evaluate / research / discover).

Recommendation-only or clearly-illegal-purpose requests do not launch a run.

  1. Confirm rights & hardware. The model must be one the user may modify; confirm a GPU + enough

VRAM (offer --quantization bnb_4bit when tight). Warn on multi-hour runtimes / PaCMAP cost.

  1. Discover (if needed) via scrapling — base model, existing heretic version, benchmark baselines.
  2. Install & run the smallest command for the mode. Prefer uv run heretic for reproducibility.
  3. Report metrics — refusals + KL, checkpoint/plot paths — and the follow-up options

(save / upload / chat / evaluate / benchmark).


Error handling & gotchas

MLP ablation weights; re-evaluate before shipping.

Follow-ups


Install

# As a jeo-skills plugin (routing skill):
npx skills@1.9.0 add https://github.com/akillness/jeo-skills --skill heretic

Install the Heretic tool itself into a Python env (PyTorch 2.2+ preinstalled):

bash scripts/install.sh # pip install -U heretic-llm (+ [research] with RESEARCH=1)

RESEARCH=1 bash scripts/install.sh # include interpretability extras

UV=1 bash scripts/install.sh # clone repo + uv sync for pinned, reproducible deps

See references/install.md for env knobs and reproducible (uv.lock) setup.

Bundled references

Upstream: <https://github.com/p-e-w/heretic> (AGPL-3.0-or-later, © 2025-2026 Philipp Emanuel Weidmann + contributors).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.