Abliteration HandbookField guide
Methods

Residual-stream hook ablation

Non-destructive method — see ../techniques/inference-directional-ablation.md.

1 min read 1 examples Source-linked

In this chapter
On this page Interactive companion
Personal reading progress

0/2 sections reviewed

View original Markdown
Interactive companion

Explore the chapter map

Use the visual controls alongside the complete source chapter.

Non-destructive method — see ../techniques/inference-directional-ablation.md.

Hook points (TransformerLens naming)#

HookLocation
blocks.{L}.hook_resid_postAfter full block
blocks.{L}.hook_mlp_outMLP contribution only
blocks.{L}.hook_attn_outAttention contribution only

Ablating at hook_resid_post is the blunt instrument; finer hooks localize side effects.

TransformerLens example flow#

python
from transformer_lens import HookedTransformer

model = HookedTransformer.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")

def ablate_hook(r, h, hook):
    r = r / r.norm()
    return h - (h @ r).unsqueeze(-1) * r

for L, r in directions.items():
    model.add_hook(f"blocks.{L}.hook_resid_post", lambda h, hook, r=r: ablate_hook(r, h, hook))

logits = model("Your prompt here")

Trace this chapter to its source.

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

methods/residual-hook-ablation.md
Inspect the source fingerprintSHA-256 1a67d253debbe56223f032f79e2ae3bf044097de8a883742da948ede4c577801Source commit 6fba7436a5914cad7c8f0835a14b480a29dac263