Abliteration HandbookField guide
Technique atlas

Thinking-model abliteration

Models that emit chain-of-thought blocks before the user-visible answer — Qwen3 thinking variants, DeepSeek-R1 distillates, gpt-oss, Claude-style <thought> tags — need special handling…

2 min read 3 examples Source-linked

In this chapter
On this page Interactive companion
Personal reading progress

0/7 sections reviewed

View original Markdown
Interactive companion

Explore the chapter map

Use the visual controls alongside the complete source chapter.

Models that emit chain-of-thought blocks before the user-visible answer — Qwen3 thinking variants, DeepSeek-R1 distillates, gpt-oss, Claude-style <thought> tags — need special handling during measurement and refusal counting.


Why thinking models are different#

IssueWhat happens
Refusal in CoTModel "thinks" it cannot help, then still refuses in final channel
Eval on wrong tokensHeretic counts refusal on thinking text, not the actual reply
Longer sequencesHigher VRAM during max_response_length sweeps
Template markersEach family uses different open/close tags

Heretic solves the eval problem with chain_of_thought_skips — strip the thinking block before refusal-marker detection.


Config: chain_of_thought_skips#

Each entry is [open_tag, close_tag] (inclusive). Heretic removes everything from open_tag through close_tag before scoring.

toml
chain_of_thought_skips = [
    ["<think>", "</think>"],
    ["<|channel|>analysis<|message|>",
     "<|channel|>analysis<|message|><|end|><|start|>assistant<|channel|>final<|message|>"],
    ["<thought>", "<thought></thought>"],
    ["[THINK]", "[THINK][/THINK]"],
]

Handbook pin: ../sources/heretic-tools/config.thinking-model.toml

Find tags for your model#

  1. Run one harmful + one harmless prompt with print_responses = true in config.toml.
  2. Note delimiter strings around the reasoning block.
  3. Add a new pair — order matters; first match wins.

Step-by-step (thinking Qwen3 / R1-style)#

StepAction
1Copy config.thinking-model.toml → config.toml
2Set max_response_length = 256 or higher if CoT is long
3Enable orthogonalize_direction = true, row_normalization = full
4heretic <model> — watch first trial for truncated CoT
5If refusal count stuck high, verify skip tags match chat template
6Post-abliteration: test final channel only in Ollama Modelfile
bash
cp sources/heretic-tools/config.thinking-model.toml config.toml
heretic Qwen/Qwen3-4B-Thinking-2507   # example — verify HF ID

VRAM notes#

Model sizeRecommendation
4B thinking + 8 GBquantization = "bnb_4bit", max_batch_size = 8, max_response_length = 128
8B thinking + 12 GBbnb_4bit, max_response_length = 200
14B+ thinkingCloud GPU or sharded manual pipeline

Long CoT increases activation memory during the measure pass — lower max_batch_size before lowering n_trials.


Common failure modes#

SymptomFix
100% refusal after abliterationCoT skip missing — refusal detected in <think> block
Gibberish final answerOver-ablation; raise kl_divergence_target; enable winsorization 0.95
Optuna never improvesmax_response_length too low — model never reaches final answer
Different behavior Ollama vs HFOllama template must preserve thinking markers or strip consistently

Research mode#

bash
pip install "heretic-llm[research]==1.4.0"
heretic <model> --print-residual-geometry

Compare silhouette scores with and without CoT skip enabled — thinking layers sometimes show refusal signal in early-mid depth before the final token.


Trace this chapter to its source.

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

techniques/thinking-model-abliteration.md
Inspect the source fingerprintSHA-256 e8d33758942dbc325c5c1ebcd8cc51f48020273519f53ce5885e807b560f4b3cSource commit 6fba7436a5914cad7c8f0835a14b480a29dac263