Heretic
Heretic 详解:用于语言模型研究的自动化 abliteration
介绍方向消融、Optuna 优化、评估与安全边界。

你将学会
- Explain the KL/refusal optimization objective
- Run a pinned model experiment
- Design broader safety evaluation
开始前需要
- Basic Git and command-line usage
- Comfort reading a project README
You can explain the project, run its documented first step, and decide what to verify before adopting it.
先看结论
- Heretic automates directional ablation with an Optuna search.
- Metrics depend on model, prompts, versions, and hardware.
- Reproducibility and human safety review are required.
The short answer
Heretic 通过方向消融和 Optuna 参数搜索修改 Transformer 模型,在减少拒答与保持原模型行为之间做优化;指标依赖模型、提示集和硬件,不能替代人工审查。
This is an experimental research workflow, not a guarantee of safe or capable behavior. The documented metrics come from a particular model, prompt set, PyTorch version, and GPU; human evaluation and licensing checks remain mandatory.
Run a controlled experiment
The documented path uses Python 3.10+, PyTorch 2.2+, and `pip install -U heretic-llm`, followed by a model identifier. A source checkout can use the supplied `uv.lock`. Start with a model you are licensed to download, a private workspace, and a small benign/safety-sensitive evaluation set.
Heretic benchmarks the machine to select a batch size and can use bitsandbytes 4-bit quantization. Preserve the exact command, model revision, dependency lock, hardware, configuration, and generated checkpoint.
How the implementation works
The tool estimates residual directions from prompt groups, orthogonalizes attention output and MLP down-projection matrices against those directions, and lets Optuna explore the parameters. Optional research features project residuals with PaCMAP and emit per-layer plots.
A low KL score or fewer refusals cannot establish factuality, privacy, or misuse resistance. Compare original and transformed models on a broader, versioned suite and keep experiments isolated before sharing a result.
When it fits
Use Heretic for interpretability research and controlled ablation experiments. Do not deploy a transformed model solely because one benchmark improved; require human safety review and follow the model's license.
如何选择
| 比较维度 | 方案 A | 方案 B |
|---|---|---|
| Best when | You need predictable behavior and easy auditing | You need adaptive optimization and have reliable telemetry |
| Main risk | May leave performance on the table | Can become difficult to explain or debug |
实施步骤
- 1
Confirm licensing and isolate the experiment.
- 2
Install a pinned Python/uv environment.
- 3
Run baseline and transformed evaluations.
- 4
Review behavior before sharing or serving a checkpoint.
可复制示例
python3.10 -m venv .venv
source .venv/bin/activate
pip install -U heretic-llm
heretic Qwen/Qwen3-4B-Instruct-2507常见问题
Does Heretic train a model from scratch?
No. It transforms selected weights and searches ablation parameters.
Are the README metrics universal?
No. Reproduce them with the same model, prompts, software, and hardware before comparing.
资料来源
- Heretic README (captured 2026-08-31)来源核查 2026-08-31
- Heretic repository来源核查 2026-08-31