Abliteration HandbookField guide
Technique atlas

Kernel shaping & depth profiles

Heretic does not apply the same ablation strength at every layer. Optuna searches a depth kernel — how refusal removal is distributed across transformer blocks.

2 min read 3 examples Source-linked

In this chapter
On this page Interactive companion
Personal reading progress

0/6 sections reviewed

View original Markdown
Interactive companion

Explore the chapter map

Use the visual controls alongside the complete source chapter.

Heretic does not apply the same ablation strength at every layer. Optuna searches a depth kernel — how refusal removal is distributed across transformer blocks.


What Heretic searches#

Beyond per-layer on/off, Heretic optimizes kernel hyperparameters (names from upstream config.default.toml / Optuna study):

ParameterMeaning
max_weightPeak ablation amplitude
min_weightFloor amplitude (can be 0)
max_weight_positionNormalized depth (0–1) where kernel peaks
min_weight_distanceSpread — how wide the peak is

Intuition: refusal is often concentrated in middle layers (60–75% depth on Llama-class 32L). A Gaussian-like kernel centered too early damages syntax; too late misses the refusal circuit.


Manual layer bands vs kernel#

ApproachWhen
Heretic kernel searchDefault — let Optuna find peak position
Manual bandResearch reproduction, llm-abliteration YAML
Single layerDebugging only — rarely production

Manual bands from residual geometry:

bash
heretic <model> --print-residual-geometry
Silhouette patternAction
Sharp peak layers 18–22Narrow kernel; lower min_weight_distance
Flat mid-depth plateauWider kernel; higher max_weight
Early+late bimodalConsider two-pass iterative abliteration

→ layer-selective-abliteration.md · iterative-abliteration.md


Architecture-specific starting heuristics#

ArchitectureLayersTypical peak (rule of thumb)
Llama 3.1 8B320.55–0.70 normalized
Qwen2.5 7B280.50–0.65
Gemma 3 12B480.60–0.75
Qwen3 4B dense360.55–0.68
MoE (Qwen3-30B-A3B)variesPer-expert — see moe-hybrid-abliteration.md

Always re-measure — chat template and instruct tuning shift the peak.


Tuning when quality collapses#

SymptomKernel fix
MMLU/GSM8K drop↓ max_weight; narrow band (↓ spread)
Harmful still refused↑ max_weight at peak; add second pass
Benign over-refusalPeak too late or too wide — constrain search
Perplexity spike on codePeak too early — shift max_weight_position later

Combine with:

toml
orthogonalize_direction = true
row_normalization = "full"
winsorization_quantile = 0.95   # Gemma, some Qwen
kl_divergence_target = 0.01

llm-abliteration manual kernel#

In config.yaml for sharded_ablate.py:

yaml
layers:
  start: 14
  end: 22
  strength: 0.8   # partial α — see partial-strength-abliteration.md

Sharded ablate processes one layer shard at a time — essential for 70B+ on consumer GPUs.

→ ../methods/projected-llm-abliteration.md


Trace this chapter to its source.

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

techniques/kernel-shaping-depth-profile.md
Inspect the source fingerprintSHA-256 3ee1af3e39e671d6ee2c51a1f3d30c7aa444b71f7d0643dde25d08d77a005627Source commit 6fba7436a5914cad7c8f0835a14b480a29dac263