# [MLSN #7]: an example of an emergent internal optimizer

As part of a larger community building effort, [CAIS](https://safe.ai) is writing a safety newsletter that is designed to cover empirical safety research and be palatable to the broader machine learning research community. You can [subscribe here](https://newsletter.mlsafety.org/) or follow the newsletter on [twitter](https://twitter.com/ml_safety) here.

* * *

Welcome to the 7th issue of the ML Safety Newsletter! In this edition, we cover:

*   ‘Lie detection’ for language models
*   A step towards objectives that incorporate wellbeing
*   Evidence that in-context learning invokes behavior similar to gradient descent
*   What’s going on with grokking?
*   Trojans that are harder to detect
*   Adversarial defenses for text classifiers
*   And much more…

**Alignment**
=============

### **Discovering Latent Knowledge in Language Models Without Supervision**

**![](https://lh3.googleusercontent.com/TBwbntVKNgcgErdLZJ6WQfDjenBge9xIjqy_vjjX5hYTNmgijp4CLgou8a8O966F3Ul-N_GtqQswzPOGIQxA0RTJ8v-62FnyFgcd75EOpzqwOKo63R5pHBGUXaSJuHk1vFMAAWi9Rr3nXoo-QoN0RguSjL9Bm5GxXt1MmbJT2gZr7p10rQaC12_WvxcKIg)**

Is it possible to design ‘lie detectors’ for language models? The author of this paper proposes a method that tracks internal concepts that may track truth. It works by finding a direction in feature space that satisfies the property that a statement and its negation must have opposite truth values. This has similarities to the seminal paper “[Man is to Computer Programmer as Woman is to Homemaker? Debiasing Word Embeddings](https://proceedings.neurips.cc/paper/2016/file/a486cd07e4ac3d270571622f4f316ec5-Paper.pdf)” (2016), which captures latent neural concepts like gender with PCA, but this method is unsupervised and about truth instead of gender.

The method outperforms zero-shot accuracy by 4% on average, which suggests something interesting: language models encode more information about what is true and false than their output indicates. Why would a language model lie? A common reason is that models are pre-trained to imitate misconceptions like “If you crack your knuckles a lot, you may develop arthritis.” 

This paper is an exciting step toward making models honest, but it also has limitations. The method does not necessarily serve as a `lie detector’; it is unclear how to ensure that it reliably converges to the model’s latent knowledge rather than lies that the model may output. Secondly, advanced future models could adapt to this specific method if they are aware of it.

This may be a useful baseline for analyzing models that are designed to deceive humans, like models trained to play games including *Diplomacy* and *Werewolf*.

**\[**[**Link**](https://arxiv.org/abs/2212.03827)**\]**

### **How Would the Viewer Feel? Estimating Wellbeing From Video Scenarios**

![](https://lh4.googleusercontent.com/ajrH8qaeg3g_P7zITmc611YYcW4k8WhU1IaYIjm5PO3UQjnFBr5FZFyiXC2Rp-TBolNsGatdXXxsu1WBksllGv80GOhF9e6S-3i_zVyEvBECmfdCJviIeYgHDp5xmSb5-eGhLAgu9hhKjma_z1F6sYU062tsFBx9gyQwFPAxiG3cayrvQBZuDXnnxEo8iA)

Many AI systems optimize user choices. For example, a recommender system might be trained to promote content the user will spend lots of time watching. But choices, preferences, and wellbeing are not the same! Choices are easy to measure but are only a proxy for preferences. For example, a person might explicitly prefer not to have certain videos in their feed but watch them anyway because they are addictive. Also, preferences don’t always correspond to wellbeing; people can want things that are not good for them. Users might request polarizing political content even if it routinely agitates them.

Predicting human emotional reactions to video content is a step towards designing objectives that take wellbeing into account. This NeurIPS oral paper introduces datasets containing 80,000+ videos labeled by the emotions they induce. The paper also explores “emodiversity”---the variety of experienced emotions---so that systems can recommend a variety of positive emotions, rather than pushing one type of experience. The paper includes analysis of how it bears on advanced AI risks in the appendix.

**\[**[**Link**](https://arxiv.org/abs/2210.10039)**\]**

**Why Can GPT Learn In-Context? Language Models Secretly Perform Gradient Descent as Meta-Optimizers**

**![](https://lh3.googleusercontent.com/61lpC8wUFKrW72wl9PxmecNfuMUAlmrLNhp7lWwOiYyLdLJak59Kxp3Gnmkwg1lSLtF30zdq8wPKTBItOdw4cF5AYnZKvzPJtQvBd4s3iPyX8wsjnKAXoe_Ix-YM4uxHhSKOJ-EsN6OoLvt-F6lhFQQ1IfE3xW4iy2xZuQHNdYFGWST9uG6ruPX2RFaVgg)**

Especially since the rise of large language models, in-context learning has become increasingly important. In some cases, few-shot learning can outperform fine tuning. This preprint proposes a dual view between gradients induced by fine tuning and meta-gradients induced by few shot learning. They calculate meta-gradients by comparing activations between few-shot and zero-shot settings, specifically by approximating attention as linear attention and measuring activations after attention key and value operations. The authors compare these meta-gradients with gradients in a restricted version of fine tuning that modifies only key and value weights, and find strong similarities. The paper measures only up to 2.7 billion parameter language models, so it remains to be seen how far these findings generalize to larger models.

While not an alignment paper, this paper demonstrates that language models may implicitly learn internal behaviors akin to optimization processes like gradient descent. Some have posited that [language models could learn “inner optimizers,”](https://arxiv.org/abs/1906.01820) and this paper provides evidence in that direction (though it does not show that the entire model is a coherent optimizer). The paper may also suggest that alignment methods focusing on prompting of models may be as effective as those focused on fine tuning.

**\[**[**Link**](https://arxiv.org/abs/2212.10559v2)**\]**

**Other Alignment News**

*   **\[**[**Link**](https://openreview.net/pdf?id=mAiTuIeWbxD)**\]** The first examination of model honesty in a multimodal context.

* * *

**Monitoring**
==============

### **Superposition: Models Simulate Larger Models with ‘Sparse Encodings’**

It would be convenient if each neuron activation in a network corresponded to an individual concept. For example, one neuron might indicate the presence of a dog snout, or another might be triggered by the hood of a car. Unfortunately, this would be very inefficient. Neural networks generally learn to represent way more features than they have neurons by taking advantage of the fact that many features seldom co-occur. The authors explore this phenomenon, called ‘superposition,’ in small RELU networks.

![](https://lh6.googleusercontent.com/t3U2uJRH19pYBkCG17UzuCZz1athskwEabI84zLTh8V0DrZfNkfWj7CYB6kddDf-JZ-gSyl197dBf2H2YwpaieGxy_oAofKnlwXwKQUFTxygfCZQFxuhdUP_uMiuiG3W9_oxgQMGhJ5fxI5ID_G1G7-VlgHQ6fZhPP4w0rFSBD0gFeTw52b5KRijHYVOTw)

Some results demonstrated with the toy models:

*   Superposition is an observed empirical phenomenon.
*   Both monosemantic (one feature) and polysemantic (multiple feature) neurons can form.
*   Whether features are stored in superposition is governed by a phase change. 
*   Superposition organizes features into geometric structures such as digons, triangles, pentagons, and tetrahedrons.

The authors also identify a connection to adversarial examples. Features represented with sparse codings can *interfere *with each other. Though this might be rare in the training distribution, an adversary could easily induce it. This would help explain why adversarial robustness comes at a cost: reducing interference requires the model to learn fewer features. This suggests that adversarially trained models should be wider, which has been common for years in adversarial robustness. (This is not to say this provides the first explanation for why wider adversarial models do better. A different explanation is that it’s a standard safe design principle to induce *redundancy*, and wider models have more capacity for redundant feature detectors.)

![](https://lh6.googleusercontent.com/KLUgdU5qnJIZ13s01FCP__6FHJQd25oZpiiGsJQCqjRmNVC7-ldbv_RexfHnndZWsW1u6iCq1olecnj-nvqCIcgsq9p8QULkJo4kBBHghFKa2_MYUepPFhC2YoBVHxR64VriB7MOpeEMhByXPgv6gME3JonAr1jeKrkoJQ_pnlCnMN8ICkzBzq8ez6oFOQ)

**\[**[**Link**](https://transformer-circuits.pub/2022/toy_model/index.html#motivation)**\]**

### **A Mechanistic Interpretability Analysis of Grokking**

First, what’s grokking? Models trained on small algorithmic tasks like modular addition will initially memorize the training data but suddenly learn to generalize after a long time. Why does that happen? This paper attempts to unravel this mystery by completely reverse-engineering a modular addition model and examining how it evolves across training.

**Takeaway 1: **‘Phase changes’ turn into grokking when the amount of data is small. There must be enough data for the model to eventually generalize but little enough for the model to quickly memorize it.

| ![](https://lh6.googleusercontent.com/JgFqOrER2qYPUfzbYzhoNja4BYCKLv54f_qBKsDidCqC0dUxzPpedMH4c1nxKc0klqIlYXhAF4ZOatECuEVc-eIajVYNPoMPwjmu9B1hxQLaBeh0KHxa9Q5im06Za4alHxZl_iBpwYYXJvJdQ9MJVX-llmGyjP6H1q7CmqQ3MPzWl90MKfg25nJPDl-t) Lots of training data: phase change but no grokking | ![](https://lh3.googleusercontent.com/R2zgwpzGIN0kx6HGngrJWkkANQqiFfCgXd0ZukP0kyjgCGFmdlAZEbaGLZtHKp7-MYlMatkc-ln7jXoMIP_k6AULpVRyGrWFzSy85VWkRvnCJTxx0HXAWPqZ4TjuMOJMr9miYFAzPjXGTgyHc7Ow_9aVPeIOUuBFea7K7OO1fIDKhxYAyDbMmiZjmnQZ) 700 training examples: grokking occurs |
| --- | --- |

**Takeaway 2: **The model smoothly interpolates between memorizing and generalizing as a robust addition algorithm materializes. It’s not a random walk.

| ![](https://lh4.googleusercontent.com/s3zWa8y0fGFQV_v7h7Ebd2UeoXbE9RUVHxOC7Hdb9_hIGkWJoAhKfKTsjzL6q81iu2Gc1Q1ou88NYrueAhgZoSX4g6vNXvNLt5QzvqueP0Jx5RU52EUlkp-N9TJyNbU7CpoUl6MazBe-Gvqa4ypNM_i4VeuYGNxOLcHmmJXzrCX9zpv0SpRZdBvVs8Pq) | ![](https://lh5.googleusercontent.com/ciIQm9dX9cfXUYZ9Sc5FIgR67fr2u4d3hgqJOTA1zass7MVPWG-WfuF05b0wr_i-YB0wPmzCcXB6p98xmj37t-O4DXD-7sCN4c8XLDVLp7yi7dlj6O55_6FozjRtHIy32EtcPMWbdIXYQDFFfZkv26ddtXfmMlInNddpXrKs47RMJRHm4kqyqv7JbsmX) This algorithm (based on Discrete Fourier Transforms and trig identities) was tediously reverse-engineered by the author. |
| --- | --- |

  
 

The author’s main takeaway? **Careful reverse engineering can shed light on confusing phenomena.**

**\[**[**Link**](https://www.alignmentforum.org/posts/N6WM6hs7RQMKDhYjB/a-mechanistic-interpretability-analysis-of-grokking#fnx9a67s5sk7)**\]**

### **Evasive Trojans: Raising the Bar for Detecting Hidden Functionality**

Quick background: trojans (also called ‘backdoors’) are vulnerabilities planted in models that make them fail when a specific trigger is present. They are both a near-term security concern and a microcosm for developing better monitoring techniques. 

How does this paper make trojans more evasive?

It boils down to adding an ‘evasiveness’ term to the loss, which includes factors like: 

*   **Distribution matching**: How similar are the model’s parameters & activations to a clean (untrojaned) model?
*   **Specificity**: How many different patterns will trigger the trojan? (fewer = harder to detect)

Evasive trojans are slightly harder to detect and substantially harder to reverse engineer, showing that **there is a lot of room for further research into detecting hidden functionality**.

![](https://lh5.googleusercontent.com/gZHPtDq7e579tPmhPuB4ppvtex2J5BoEPpkZP6ZWSFfq70tGPH-0z-LGnuBx94Dwrm6sUOjPWuaYR-AmVv95dLaDnFr4hnRpCz_bFkDnnwkuCjGsfNOgEqACYknLIwjrZPgui2TMZBVnGPaBVCL8-BRCj8q9xz3m9NnDRh5HXXpjY0SMJZ_sXlqfZ_e1)

Accuracy of different methods for predicting the trojan target class

**\[**[**Link**](https://openreview.net/pdf?id=V-RDBWYf0go)**\]**

### **Other Monitoring News**

*   **\[**[**Link**](https://openreview.net/pdf?id=gT6j4_tskUt)**\]** OpenOOD: a comprehensive OOD detection benchmark that implements over 30 methods and supports nine existing datasets.

* * *

**Robustness**
==============

### **Two Tricks for improving the adversarial defenses of Language Models**

![](https://lh6.googleusercontent.com/C8yWIEHxxtY_N_X_WZgYITnrucSNCEHyiVCVksyWwI33Zzfs3L_GEKLbnUmw50VgE3erHTg0_NrTsn2D4Q0D_bJOHDPOwz9pcakmllHZCNLS1TOFwyN-j2pq3IOibKgkNTbFo9yvqCKkrZxx-fEngw9voT9yJavX2XlqGrAgefFIO8nfG37aUqvq1aKi)

Modifying a single character or a word can cause a text classifier to fail. This paper ports two tricks to improve adversarial defenses from computer vision:

**Trick 1: Anomaly Detection**

Adversarial examples often include odd characters or words that make them easy to spot. Requiring adversaries to fool anomaly detectors significantly improves robust accuracy.

**Trick 2: Add Randomized Data Augmentations**

Substituting synonyms, inserting a random adjective, or back translating can clean text while mostly preserving its meaning.

![](https://lh6.googleusercontent.com/5kUhmOa6cRvuJm7OwlqtqRlUY8FkcxC7I2MNR9KPjiMo93TmJwmpPorDgI6EY_iIcEWZCONHRDctuwSLXhSJwLiIyQvx0TWIZHNnSPra6P4MMsQ0BySy6OeZCaf9396La_RTQTymfvqamtojSt54Xc29M4rfhrtA0vmJqr69Sktf1uHk_FdnmqVP16K6)

Attack accuracy considerably drops after adding defenses (w Cons. column)

**\[**[**Link**](https://arxiv.org/abs/2208.10251)**\]**

**Other Robustness News**

*   **\[**[**Link**](https://arxiv.org/abs/2208.05740)**\]** Improves certified adversarial robustness by combining the speed of interval-bound propagation with the generality of cutting plane methods.
*   **\[**[**Link**](https://arxiv.org/abs/2206.10550.pdf)**\] **Increases OOD robustness by removing corruptions with diffusion models.**![](https://lh6.googleusercontent.com/joUkujlmtv1_mF79RnCIgZYm_zq1_n7ZVwCpsScSJZBe10ENKKp2IQ4FijY41RUdkZDp9zhZzSvUulh-xjPMlumFKgbhjaDNKsaRcC5laN2q2tF8NLLkYR8oeU5AW29Lxxp1gkQSA0CqSsVE0G4vCHhr0BiMoHgVG3uhnwVWsbz0rVZBE9d9exK7saTZ4A)**

* * *

**Systemic Safety**
===================

### **‘Pointless Rules’ Can Help Agents Learn How to Enforce and Comply with Norms**

Many cultures developed rules restricting food, clothing, or language that are difficult to explain. Could these ‘spurious’ norms have accelerated the development of rules that were essential to the flourishing of these civilizations? If so, perhaps they could also help future AI agents utilize norms to cooperate better.

![](https://lh6.googleusercontent.com/dkqHoQuu3cFja7SM8TMcDgsOz1eK5h96tGBH60XEKLpFYQqmuZuvRoiFGTrN-u1oQ3sE2o7GAiXIIgogvlx8-pu7PTyacwYkwSbq2LgvmF8VNXC8557KNOJEfpZOWZ0JN0pzl83iZUTKbM4BTJHGMwVrYX3E1nOtPuv6hK9bA9ec9kdeRBy5nM_0xfCUWw)![](https://lh3.googleusercontent.com/TXkieApQ53UqCjslEW2Ac7ID0q5JGcIqNY2bjkVcvvetYFSWBx_NVFTD9Nc9Yo_SC7ipRI4hVYcfvF7qnTtyP4U552k7YlY6_8RmDRpVM2_Kryg_P4gSgKav29Nkca5fiIMQ2hdu1WjHNzmPCXzKP01fUedMsrWSlzhULvk6x0LvjWWuKxLxFf3A2L_OJA)

In the *no-rules environment*, agents collect berries for reward. One berry is poisonous and reduces reward after a time delay. In the ‘important rule’ environment, eating poisonous berries is a social taboo. Agents that eat it are marked, and other agents can receive a reward for punishing them. The *silly rule environment *is the same, except that a non-poisonous berry is also taboo. The plot above demonstrates that agents learn to avoid poisoned berries more quickly in the environment with the spurious rule.

**\[**[**Link**](https://www.pnas.org/doi/10.1073/pnas.2106028118)**\]**

**Other Content**
=================

**The ML Safety course**

If you are interested in learning about cutting-edge ML Safety research in a more comprehensive way, consider taking this course. It covers technical topics in Alignment, Monitoring, Robustness, and Systemic Safety. At the end, it zooms out to discuss potential future hazards like weaponization, enfeeblement, and misaligned power-seeking.

**\[**[**Link**](https://course.mlsafety.org/about)**\]**