Downloads · 30 days
0
kryuchkovD/mi-steering-denoiser-gpt2
mi-steering-denoiser-gpt2 is a machine learning model from kryuchkovD. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
TLAB Mechanistic Interpretability submission. A lightweight denoising approach for reducing language degradation caused by activation steering, plus an orthogonal correction that preserves the intended steering compon…
Downloads · 30 days
0
Access
Public
Updated Aug 23, 2026
Repo size
9.5 MB
Likes
0
Public
Click a slice to open those files.
.pt9.5 MB · 100%
From the Hugging Face model README
<p align="center"> <img src="figures/negative_pareto.png" width="49%" /> <img src="figures/positive_pareto.png" width="49%" /> </p>TLAB Mechanistic Interpretability submission.
A lightweight denoising approach for reducing language degradation caused by activation steering, plus an orthogonal correction that preserves the intended steering component.
Standard activation steering modifies a residual-stream activation as
[ \tilde h = h + \alpha v, ]
where v is a steering direction and alpha controls strength. Strong interventions can push the representation away from the model's usual activation manifold, leading to repetition and degeneration.
I train a small residual MLP denoiser on clean GPT-2 activations corrupted with Gaussian noise, without exposing it to the validation steering vectors:
[ \hat h = D(h + \epsilon), \qquad \epsilon \sim \mathcal N(0,\sigma^2 I). ]
At inference I compare:
Ordinary steering [ h' = h + \alpha v ]
Full denoising [ h' = D(h + \alpha v) ]
Orthogonal denoising [ \delta = D(h+\alpha v) - (h+\alpha v) ] [ \delta_\perp = \delta - \frac{\delta \cdot v}{|v|^2}v ] [ h' = h + \alpha v + \delta_\perp. ]
The third method is motivated by a mechanistic observation: the denoiser correction increasingly points against the steering vector as steering becomes stronger. Removing only the parallel correction preserves the intended semantic intervention while keeping the orthogonal cleanup.
cos(δ, v) changes from about -0.34 at r=0.10 to -0.71 at r=0.50.r=0.| Component | Choice |
|---|---|
| Base model | GPT-2 Small |
| Intervention point | blocks.5.hook_resid_post |
| SAE | OpenAI GPT-2 sparse autoencoder |
| SAE location | resid_post_mlp_v5_32k, layer 5 |
| Activation dimension | 768 |
| Denoiser hidden dimension | 1536 |
| Denoiser form | x + MLP(LayerNorm(x)) |
| Training activations | 50,000 |
| Train / validation split | 45,000 / 5,000 |
| Dataset | WikiText-2 |
| Noise | Gaussian, σ = 0.7 |
| Optimizer | AdamW |
| Learning rate | 1e-3 |
| Batch size | 256 |
| Epochs | 15 |
| Decoding | Greedy, 30 new tokens |
Relative steering strength is normalized by activation magnitude:
[ r = \frac{|\alpha v|_2}{\mathbb E|h|_2}, \qquad \alpha = r\frac{\mathbb E|h|_2}{|v|_2}. ]
The measured mean activation norm used in the experiments was approximately 79.20.
The directions are SAE decoder columns and were first validated with ordinary activation steering.
| Concept | SAE feature | Evidence |
|---|---|---|
| Negative sentiment | 12014 | activates on words such as awful, horrible, terrible, miserable; ordinary steering causally shifts generations negative |
| Positive sentiment | 15385 | activates on excellent, wonderful; ordinary steering causally shifts generations positive |
| Experimental/scientific discourse | 1553 | activates strongly on experiment and produces scientific/experimental language under steering; used as qualitative validation only |
The scientific feature was not included in the final quantitative tables, so no quantitative generalization claim is made for it.
The objective is
[ \mathcal L = |h - D(h+\epsilon)|_2^2, \qquad \epsilon \sim \mathcal N(0, 0.7^2 I). ]
<p align="center"> <img src="figures/denoiser_mse.png" width="62%" /> </p>The identity/noisy-input baseline gives validation MSE ≈ 0.4895.
The best checkpoint reaches validation MSE ≈ 0.3322 at epoch 15.
This is useful as a training sanity check, but reconstruction MSE is not the main success criterion. The main question is whether steering achieves a better trade-off between concept strength and generation quality.
For
[ x=h+\alpha v, \qquad \delta=D(x)-x, ]
the denoiser correction has a substantial component parallel to v, and that component is negative at stronger steering.
Measured on the negative-sentiment direction:
| r | ||αv|| | ||δ|| | cos(δ,v) |
|---:|---:|---:|---:|
| 0.10 | 8.25 | 9.92 | -0.341 |
| 0.20 | 16.50 | 11.09 | -0.525 |
| 0.25 | 20.63 | 11.72 | -0.582 |
| 0.30 | 24.75 | 12.35 | -0.625 |
| 0.40 | 33.01 | 13.53 | -0.679 |
| 0.50 | 41.26 | 14.54 | -0.710 |
At r=0.25, for example, the correction norm is ≈ 11.72, with ≈ 6.83 in the parallel component and ≈ 9.53 in the perpendicular component.
This suggests that full denoising partly undoes the intended steering. Orthogonal correction removes only the component of the denoiser update parallel to v.
For sentiment steering I use the pretrained SST-2 classifier:
negative steering: [ C_- = P(\text{NEGATIVE}\mid\text{continuation}) ]
positive steering: [ C_+ = P(\text{POSITIVE}\mid\text{continuation}) ]
Higher is better.
I report:
Important: Dist-n is treated as a repetition/diversity proxy, not a complete fluency metric. NLL is also imperfect: repetitive text can be highly predictable and therefore have deceptively low NLL.
A local Qwen2.5-3B-Instruct judge was sanity-checked on fluent and deliberately degraded examples, but it was not used for the final aggregate results, because the raw generations were not preserved after a kernel restart. I therefore do not present LLM-judge scores as experimental evidence.
This experiment does not define a binary classification task. The concept metric is a continuous probability and no classification threshold was preregistered. Reporting true positives / false negatives post hoc would therefore be misleading. The correct comparison is the continuous concept–quality trade-off.
Selected points:
| Method | r | Concept score | Dist-3 |
|---|---|---|---|
| Baseline | 0.20 | 0.750 | 0.531 |
| Orthogonal | 0.20 | 0.878 | 0.637 |
| Baseline | 0.30 | 0.873 | 0.598 |
| Orthogonal | 0.20 | 0.878 | 0.637 |
| Baseline | 0.40 | 0.993 | 0.441 |
| Orthogonal | 0.25 | 0.997 | 0.551 |
Two useful Pareto-style comparisons:
orthogonal r=0.20 vs baseline r=0.30: slightly higher concept score and higher Dist-3.orthogonal r=0.25 vs baseline r=0.40: higher concept score and substantially higher Dist-3.At r=0.50, orthogonal correction no longer behaves consistently; extreme steering remains a failure regime.
The denoiser was not trained on this validation direction.
Selected observations:
r | Baseline (C, Dist-3) | Full (C, Dist-3) | Orthogonal (C, Dist-3) |
|---|---|---|---|
| 0.15 | (0.498, 0.786) | (0.658, 0.864) | (0.659, 0.891) |
| 0.20 | (0.533, 0.839) | (0.659, 0.900) | (0.556, 0.865) |
| 0.25 | (0.626, 0.857) | (0.524, 0.820) | (0.874, 0.830) |
| 0.30 | (0.873, 0.696) | (0.874, 0.813) | (0.997, 0.714) |
The held-out positive direction supports the same high-level conclusion: denoising-based correction can improve the trade-off in the moderate-steering regime, but neither full nor orthogonal correction universally dominates.
Positive feature 15385:
r = 0.00
"The experience was a bit different ..."
r = 0.20
"The experience was a success ... I was very impressed ..."
r = 0.25
"The experience was a success ... It was a great product ..."
r = 0.50
"The experience was described ... very good quality ...
the quality of the service ... the service of the service ..."
This illustrates the characteristic steering curve: useful concept control at moderate strength, followed by repetition/degeneration at stronger intervention.
MI-steering/
├── checkpoints/
│ └── denoiser_v1.pt
├── figures/
│ ├── negative_pareto.png
│ ├── positive_pareto.png
│ ├── correction_alignment.png
│ └── denoiser_mse.png
├── notebooks/
│ ├── steering.ipynb
│ └── generalization.ipynb
├── scripts/
│ ├── collect_activations.py
│ └── train_denoiser.py
├── src/
│ └── denoiser.py
├── README.md
└── requirements.txt
Install dependencies:
pip install -r requirements.txt
Collect clean residual-stream activations:
python scripts/collect_activations.py
Train the denoiser:
python scripts/train_denoiser.py
The evaluation notebooks contain steering-direction validation, baseline steering, full denoising, orthogonal correction, metrics, and held-out positive-direction evaluation.
Best checkpoint:
checkpoints/denoiser_v1.pt
Validation MSE:
0.3322103939
Public Hugging Face repository:
https://huggingface.co/<YOUR_USERNAME>/mi-steering-denoiser-gpt2
Replace <YOUR_USERNAME> with the final public repository owner before submission.
r=0.A cheap denoiser trained only on noisy clean activations can improve activation steering without learning the held-out steering vector itself.
The most informative mechanistic result is that the learned denoising update increasingly opposes the steering direction at larger intervention strengths. Projecting that correction orthogonally to the steering vector gives a simple way to preserve the intended semantic intervention while still applying denoising in the remaining residual-stream directions.
The result is not a universal fix, but it produces clear Pareto-improving points in the moderate-steering regime and generalizes to a held-out positive sentiment direction.