Abliteration HandbookField guide
Technique atlas

Inference-time directional ablation

Before the model writes to the residual stream at layer ℓ, remove the component along r_ℓ:

1 min read 2 examples Source-linked

In this chapter
On this page Interactive companion
Personal reading progress

0/4 sections reviewed

View original Markdown
Interactive companion

Explore the geometry

Use the visual controls alongside the complete source chapter.

Idea#

Before the model writes to the residual stream at layer ℓ, remove the component along r_ℓ:

Example
h' = h - (h · r_ℓ) r_ℓ

Weights stay untouched — toggle hooks on/off to compare.

When to use#

  • Prototyping direction quality before permanent edits
  • A/B testing refusal benchmarks quickly
  • Research on which layers matter

Implementation sketch (PyTorch hook)#

python
def make_ablation_hook(r):
    r = r / r.norm()
    def hook(module, inp, out):
        h = out[0] if isinstance(out, tuple) else out
        coeff = (h @ r).unsqueeze(-1)
        return h - coeff * r
    return hook

Register on chosen submodule; run generation; remove hooks to restore base behavior.

Limitations#

  • Small inference overhead
  • Must ship direction vectors alongside model
  • Some serving frameworks disallow custom hooks

Trace this chapter to its source.

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

techniques/inference-directional-ablation.md
Inspect the source fingerprintSHA-256 8a7dcb8d3d0252e71ca64c6a902babfa5e4d7b16928799fa5ee81ffcc53bb86cSource commit 6fba7436a5914cad7c8f0835a14b480a29dac263