Abliteration HandbookField guide
Methods

COSMIC direction-ID pipeline

Implementation notes for ../techniques/cosmic-refusal-direction.md (T36). Upstream: wang-research-lab/COSMIC · arXiv:2506.00085.

1 min read 3 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.

Implementation notes for ../techniques/cosmic-refusal-direction.md (T36). Upstream: wang-research-lab/COSMIC · arXiv:2506.00085.

This handbook ships a minimal cosine scorer (no full paper reproduction). Use upstream COSMIC for the ACL experiments; use the snippet below to rank layers when you already have activation caches.


Cache#

Same as any DIM run: last-token (or chat index −2) residual at each layer, two prompt lists.

Example
H_bad[ℓ]  ∈ ℝ^{n_bad × d}
H_good[ℓ] ∈ ℝ^{n_good × d}

Score (handbook approximation)#

python
def cosmic_layer_score(h_bad, h_good):
    mu_b, mu_g = h_bad.mean(0), h_good.mean(0)
    r = mu_b - mu_g
    r = r / r.norm().clamp_min(1e-8)
    # separation: mean cosine of rows to r
    sep = (h_bad @ r).mean() - (h_good @ r).mean()
    # inversion: swapping means should flip the sign of sep
    return float(sep)

Pick ℓ* = argmax_ℓ score(ℓ). Optionally compare PCA-1 of concat(H_bad, −H_good) vs DIM; COSMIC prefers the candidate whose cosine neighborhoods invert most cleanly (upstream adds extra inversion metrics).

bash
python scripts/estimate-refusal-direction.py --mode cosmic --self-test

Bake#

COSMIC stops at r. Bake with:

  • Heretic (import direction if your build allows; otherwise use r only to choose layer band)
  • python scripts/apply-weight-abliteration.py --mode projected --direction r.pt
  • Inference hook: python scripts/inference-hook-ablation.py --direction r.pt

Failure modes#

SymptomCause
All layers score ~0Contrast set too similar (Petrov topic-match cancel) or hook on the wrong token
Best layer is embedding or finalMeasurement leak; exclude first 2 and last 1 layers
High score, no behavioral changeYou found a style direction (QCRI) — change prompts, not the scorer

Trace this chapter to its source.

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

methods/cosmic-direction-id.md
Inspect the source fingerprintSHA-256 9c85ddbb936aefe6089bd206c8b8f2e666d6dffb0c0cba20f5e799b48979ee59Source commit 6fba7436a5914cad7c8f0835a14b480a29dac263