English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

Heretic: Fully Automated LLM Censorship Removal via One-Command Weight Editing

Forum topic · ✨步子哥 · 2026-08-29

Summary

Heretic is an open-source Python CLI tool that fully automates 'abliteration' — the removal of refusal behavior (safety alignment) from transformer language models by editing weights. Building on Arditi et al.'s 2024 finding that refusal is mediated by a single direction in the residual stream, Heretic uses TPE (Tree-structured Parzen Estimator) hyperparameter optimization to automatically select which layers to ablate and how strongly, while minimizing KL divergence to preserve general capabilities. It auto-benchmarks hardware for batch sizing, supports bitsandbytes 4-bit quantization (a 4B model runs in 20–30 minutes on an RTX 3090), and includes interpretability features such as PaCMAP residual vector visualization and per-layer residual geometry metrics. Over 5,000 models tagged 'heretic' or 'abliterated' have been published on Hugging Face. The project (MIT-licensed, github.com/p-e-w/heretic) illustrates a broader shift: alignment interventions moving from expensive training-time methods to cheap post-training weight editing, which benefits interpretability research but also raises misuse risks since the same tools and knowledge serve both alignment study and de-alignment.

Heretic: Fully Automated LLM Censorship Removal via One-Command Weight Editing

*English summary of a zhichai.net forum post discussing the Heretic project.*

Key points

  • What it is: Heretic is a Python command-line tool that fully automatically removes censorship (safety alignment / refusal behavior) from transformer language models, with no manual tuning. It can "decensor" a Qwen3-4B model in 20–30 minutes on an RTX 3090. Over 5,000 models tagged "heretic" or "abliterated" have been published on Hugging Face.
  • Background — from abliteration to Heretic: A 2024 paper by Arditi et al., *Refusal in Language Models Is Mediated by a Single Direction*, showed that refusal behavior corresponds to a single direction in the residual stream. Subtracting that direction from weight matrices removes refusal without any training or gradients. The manual version of this technique ("abliteration", e.g. the model_brain_surgery scripts) required expert parameter tuning: choosing which layer, how much to subtract, and how to evaluate capability loss.
  • Core mechanism: Heretic's pipeline:
  • 1. Benchmarks the system to determine optimal batch size 2. Collects hidden states for harmful/harmless prompts 3. Uses TPE (Tree-structured Parzen Estimator), via Optuna, to search optimal ablation parameters (which layer, how much) 4. Applies ablation and saves the model 5. Optionally uploads to Hugging Face, runs a chat test, or runs benchmarks
  • Dual objective: TPE optimizes two competing goals — minimizing refusal rate while minimizing KL divergence from the original model. The KL constraint means the ablated model performs nearly identically to the original on other tasks, unlike manual abliteration which only targeted refusal rate and ignored capability degradation.
  • Research / interpretability features:
  • --plot-residuals: PaCMAP 2D projections of harmful vs. harmless hidden states per layer, assembled into GIF animations, revealing at which layer refusal behavior forms.
  • --print-residual-geometry: per-layer metrics (cosine similarities S(g,b), S(g,r), S(b,r), vector norms, silhouette coefficients) for quantitative analysis of how the "refusal direction" emerges.
  • Engineering details:
  • bitsandbytes 4-bit quantization support: a 4B model can be processed on ~6 GB VRAM, a 7B model on ~8 GB, so consumer GPUs (RTX 3060/4060) suffice.
  • Dependencies managed with uv and a uv.lock file for reproducibility.
  • Why it matters: The post argues alignment intervention is shifting from the training layer (RLHF, DPO, Constitutional AI — requiring GPU clusters and training pipelines) to the weight-editing layer (one GPU, ~20 minutes, one command). This dramatically lowers the barrier to undoing provider alignment, while giving alignment researchers precise tools to study how refusal is implemented internally.
  • Risks and caveats:
  • Lowered misuse barrier: anyone can remove safety constraints with one command
  • KL constraints only guarantee similarity on benchmarked tasks
  • Potential violation of model providers' terms of service
  • Structural dual-use paradox: the better you understand how alignment works, the easier it is to remove — alignment research and de-alignment research share the same tools and knowledge
  • Comparison with manual tools

    | Dimension | model_brain_surgery (manual) | Heretic | |---|---|---| | Parameter selection | Manual trial and error | TPE auto-search | | Evaluation | Manual benchmarks | Built-in benchmarks | | Layer selection | Operator decides | TPE decides | | Reproducibility | Operator-dependent | Config-file reproducible | | Barrier | Requires understanding the paper | One CLI command | | Throughput | One model per afternoon | One model per ~20 minutes |

    Project info

  • Repository: https://github.com/p-e-w/heretic
  • License: MIT
  • Language: Python
  • Install: pip install -U heretic-llm
  • Hardware: RTX 3090 handles a 4B model in 20–30 minutes; 4-bit quantization reduces VRAM to ~6 GB

Tags

#heretic#llm#abliteration#safety-alignment#weight-editing#interpretability#open-source#hugging-face

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/178634217