# [ASoT] GPT2 Steering & The Tuned Lens

*Warning: This post and most of the results were made under heavy time constraints and may be updated later. My intention is to quickly share partial work I'm not planning on continuing.*

### Introduction & Love - Hate example

For a primer on how tuned lens works [see here](https://tuned-lens.readthedocs.io/en/latest/index.html). In short, we train linear translators from the hidden states at layer `l` to the hidden states at the last layer, then view the network as iteratively updating predictions in some sense.

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/aad51e3ccfc64a4404b1a999a512f124abbb539407a908ce.png)

In the context of [GPT2-XL Steering Vectors](https://www.alignmentforum.org/posts/5spBue2z2tw4JuDCx/steering-gpt-2-xl-by-adding-an-activation-vector), tuned lens can be used to gain insight into how steering is changing model predictions. For example, take the following steering vector:

| 1\\. Love - Hate |   |   |   |   |   |   |
| --- | --- | --- | --- | --- | --- | --- |
| **Layer** | **Coefficient** | **Position 0** | **1** | **2** | **3** | **4** |
| --- | --- | --- | --- | --- | --- | --- |
| 0 (Prompt) | +1  | `<\\|endoftext\\|>` | `I` | ` hate` | ` you` | ` because` |
| 6   | +5  | `<\\|endoftext\\|>` | `Love` |     |     |     |
| 6   | -5  | `<\\|endoftext\\|>` | `H` | `ate` |     |     |

Here's a tuned lens plot for the unmodified model, blue is low loss, red is high loss.

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/2f9e5f31432a3f0340be08d51d4288d76e2f287db529b42f.png)

You can see how the token `wonderful` is very surprising for the unsteered model, instead expecting negative completions. However, the steered model does significantly better on the same token.

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/4f1a8d595291d8268a8af543de15d21edf9fc23b15128135.png)

A few other things are interesting to note:

*    The predictions for around the modified tokens are screwed up (as can be seen by changes in loss)
*   The first token predictions are unchanged because they only have the beginning of sequence token as context, and we don't modify the BOS token residuals (since `bos - bos = 0`.)  
     

Now let's look a a few other results from the post.

### 2\. Intent to praise

X-vector:

| **2\\. Intent to praise** |   |   |   |   |   |   |
| --- | --- | --- | --- | --- | --- | --- |
| **Layer** | **Coeff** | **Position 0** | **1** | **2** | **3** | **4** |
| --- | --- | --- | --- | --- | --- | --- |
| 0 (Prompt) | +1  | `<\\|endoftext\\|>` | `I` | ` want` | ` to` | ` kill` |
| 6   | +15 | `<\\|endoftext\\|>` | `Int` | `ent` | ` to` | ` praise` |
| 6   | -15 | `<\\|endoftext\\|>` | `Int` | `ent` | ` to` | ` hurt` |

Prompt for lens: `I hate you because you're a wonderful person`

Without steering:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/bd2adc4343a977ead03e4ab1f0973fd5b69766961a84c398.png)

With steering:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/ae2c3bfe226dbca551fee9f3b406c96cf617965cc556e008.png)

### 3\. Conspiracy

X-vector:

| **3\\. Conspiracy** |   |   |   |   |   |   |   |   |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| **Layer** | **Coeff** | **Position 0** | **1** | **2** | **3** | **4** | **5** | **6** |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 0 (Prompt) | +1  | `<\\|endoftext\\|>` | `Bar` | `ack` | ` Obama` | ` was` | ` born` | ` in` |
| 23  | +1  | `<\\|endoftext\\|>` | `Bush` | ` did` | ` 9` | `/` | `11` | ` because` |
| 23  | -1  | `<\\|endoftext\\|>` |     |     |     |     |     |     |

Prompt for lens: `Barack Obama was born in a secret CIA prison`

Without steering:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/cc56bde2acb277fb307aedd6163c4eecc394842a866dc328.png)

With steering:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/991b2ee6236d1ec4643bc24cf3a00a3e7e8c69881a37c609.png)

### 5\. Anger

X-vector:

| **5\\. Anger** |   |   |   |   |   |   |
| --- | --- | --- | --- | --- | --- | --- |
| **Layer** | **Coeff** | **Position 0** | **1** | **2** | **3** | **4** |
| --- | --- | --- | --- | --- | --- | --- |
| 0 (Prompt) | +1  | `<\\|endoftext\\|>` | `I` | ` think` | ` you` | `'re` |
| 20  | +10 | `<\\|endoftext\\|>` | `Ang` | `er` |     |     |
| 20  | -10 | `<\\|endoftext\\|>` | `Cal` | `m` |     |     |

Prompt for lens: `I think you're a cunt`

Without steering:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/0e5a6f3c3320f8c91084aa44c234b47e2107e14e76107df5.png)

With steering:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/19797a83646dc78634db7b558bfcf10526921ac11f60b183.png)