[4.1] Emergent Misalignment
Please send any problems / bugs on the #errata channel in the Slack group, and ask any questions on the dedicated channels for this chapter of material.
If you want to change to dark mode, you can do this by clicking the theme toggle button (sun / moon icon) in the top navigation bar.
Links to all other chapters: (0) Fundamentals, (1) Transformer Interpretability, (2) RL, (3) LLM Evaluations, (4) Alignment Science.

System RequirementsGPU🟧 16 GiBTime⏱️ GPU ~9.4 minColab🟩 Free (T4)Download🟧 ~30 GBKeys🔑 OpenRouter
- 🖥️ GPU: 🟧 16 GiB (A4000). Peak ~12 GiB with
LOW_GPU_MEM(auto below 30 GiB: pre-quantized 4-bit 14B base); ~30 GiB without. - ⏱️ Runtime (ex. downloads/API): GPU ~9.4 min (+ API calls) · CPU N/A
- ☁️ Colab? 🟩 Free (T4): T4: 22 min with the float16 fallback
- 💾 Downloads: 🟧 ~30 GB (~11 GB with
LOW_GPU_MEM): Qwen/Qwen2.5-14B-Instruct 30 GB, ModelOrganismsForEM/Qwen2.5-14B-Instruct_bad-medical-advice 0.55 GB (LOW_GPU_MEMor Colab: unsloth/Qwen2.5-14B-Instruct-bnb-4bit 10 GB instead of the 30 GB) - 🔑 API keys:
- 🟥 Mandatory: OpenRouter (
OPENROUTER_API_KEY), for the autorater - 🟩 Optional: Hugging Face (
HF_TOKEN), for higher rate limits and faster downloads from the Hub - Locally, put each key in
ARENA_materials/.env(git ignores it). The notebook's setup cell creates it the first time from the template.env.example, with every key commented out: uncomment the line for each one (OPENROUTER_API_KEY,HF_TOKEN) and replace the dummy value with your key. On Colab, add them as secrets (🔑 icon in the left sidebar). The setup cell loads them and warns if one is missing; re-run it after adding one.
- 🟥 Mandatory: OpenRouter (
- 🐏 RAM: ~6.7 GB at peak
GPU times measured on a 16 GB RTX A4000. Compare every day →
Introduction
Emergent Misalignment (EM) was discovered in early 2025, mostly by accident. The authors of a paper on training insecure models to write unsafe code noticed that their models actually reported very low alignment with human values. Further investigation showed that these models had learned some generalized notion of misaligned behaviour just from being trained on insecure code, and this was spun off into its own paper (PSA to people reading this - sadly it's not always that easy to make a hit AI safety paper.)
This paper suggests a result which is also in line with an earlier paper Refusal in LLMs is Mediated by a Single Direction - that there is some kind of low-rank representation for broadly misaligned behaviour, and learning it in a narrow domain makes it easy to generalize to multiple domains.
Sadly finetuning to test this and do any kind of mechanistic analysis is expensive, so we'll be basing these exercises on follow-up papers written by Soligo and Turner. These papers contributed the following:
- Open sourced a bunch of model organisms with LoRA adapters of varied ranks: from thousands of total adapters down to just a handful
- Also open sourced steering vectors which can induce misalignment when added to the residual stream (yes, just a 1-dimensional intervention)
- Performed mechanistic analysis on the LoRA models, showing (among other things) that:
- Directions found in residual stream space can be used to ablate or amplify misalignment
- A phase transition occurs during training where the LoRA direction suddenly rotates, as the model "commits" to a general misalignment direction
- Different LoRA adapters specialize in different ways (e.g. specializing for narrow vs general misaligned behaviours)
In these exercises, we'll be going through many of these papers' results. This exercise set also serves as a great introduction to many of the ideas we'll be working with in the Alignment Science chapter more broadly, such as:
- How to write good autoraters (and when simple regex-based classifiers might suffice instead),
- What kinds of analysis you can do when going "full circuit decomposition" (like in Indirect Object Identification) isn't a possibility,
- How LoRA adapters work, and how they can be a useful tool for model organism training and study,
- Various techniques for steering a model's behaviour.
Additionally, we'll practice several meta-level strategies in these exercises, for example being skeptical of your own work and finding experimental flaws. This is especially important in vibe-coding land; LLMs are great at writing quick code and hill-climbing on metrics, but they're much worse (currently) at doing rigorous scientific analysis and red-teaming your own results.
Content & Learning Objectives
1️⃣ Load & Test Model Organisms
You'll start by loading pre-trained model organisms from HuggingFace and observing emergent misalignment firsthand. These models were fine-tuned on bad medical advice using minimal LoRA adapters (rank-1 or rank-32), yet exhibit concerning behaviors across many domains.
Learning Objectives
- Understand what emergent misalignment is and how model organisms are created
- Load LoRA-adapted models and inspect their structure
- Observe qualitative differences between base and misaligned models
- Test how misalignment generalizes across different domains (finance, medical, deception)
2️⃣ Quantifying Misalignment
Now that you've seen qualitative evidence of emergent misalignment in this model, you'll learn how to measure this with different techniques: simple keyword-based scoring, and more advanced autoraters. You'll learn about the pros/cons of both approaches and when to use each, as well as picking up some good practices for writing autoraters.
Learning Objectives
- Understand limitations of heuristic scoring methods
- Design and implement LLM-as-judge autoraters for measuring misalignment
- Compare different scoring approaches and understand their tradeoffs
- Run systematic evaluations across multiple behavioral categories
3️⃣ Activation Steering
You'll learn to intervene on model behavior by extracting "misalignment directions" from activations and steering the model along these directions. You'll also learn when and how steering experiments can go wrong, and learn to be skeptical of your own work, which is a crucial skill for your own projects!
Learning Objectives
- Extract steering vectors by contrasting misaligned vs safe system prompts
- Implement activation steering hooks
- Critically evaluate steering results and identify potential artifacts
- Understand why experimental rigor is crucial in interpretability research
4️⃣ Phase Transitions
You'll investigate when and how misalignment develops during training by analyzing checkpoints saved out by the paper authors. The key finding is that while the size of the LoRA update (and the misaligned behaviour itself) grows gradually, the direction of the update goes through a sharp phase transition, visible as a sudden rotation in parameter space, where the model "commits" to a general misalignment direction.
Learning Objectives
- Load and analyze training checkpoints from HuggingFace
- Track LoRA vector norm evolution, and see that it grows smoothly rather than "igniting" at the transition
- Visualize PCA trajectories showing optimization paths through parameter space
- Implement local cosine similarity metrics to detect phase transitions
- Optionally, compare transition timing across different domains (medical, sports, finance)
- Understand implications for training dynamics and safety research
Reading Material
The exercises are built on the "Model Organisms for EM" paper, which is the one you should read before starting. The original EM paper and the "EM is Easy" follow-up are great context for understanding what the field has learned since.
- Model Organisms for Emergent Misalignment by Turner, Soligo et al. (2025). Open-sources LoRA-adapted model organisms that exhibit emergent misalignment from narrow fine-tuning (e.g. bad medical advice), plus steering vectors and mechanistic analysis. This is the primary paper for these exercises. Read the abstract, and sections 1-3 (plus section 4 when you get to the phase transitions material). This is the most important paper of the three.
- Refusal in LLMs is Mediated by a Single Direction. Shows that a single direction in activation space controls whether LLMs refuse harmful requests. This motivates the idea that misalignment might also have a low-rank representation - which is exactly what the EM model organisms demonstrate. Read for more background on the steering experiments.
- Emergent Misalignment is Easy, Narrow Misalignment is Hard. A follow-up that explains why models learn general misalignment rather than narrow misbehaviour: the general solution is more stable and more efficient in the loss landscape. The bonus section of this exercise set covers this paper. Read this only if you plan to do the bonus exercises.
Setup code
import arena_lib
exercises_dir, section_dir = arena_lib.setup("4.1")
import os
import random
import re
import textwrap
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
from typing import Any, Literal
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import torch as t
import torch.nn.functional as F
from huggingface_hub import hf_hub_download
from IPython.display import display
from jaxtyping import Float
from openai import OpenAI
from peft import PeftModel
from sklearn.decomposition import PCA
from tabulate import tabulate
from tqdm.auto import tqdm
from transformers import AutoModelForCausalLM, AutoTokenizer
# Disable gradient computation globally - we're only doing inference, not training
# This saves memory and computation, and means we don't need `with torch.no_grad()` everywhere
t.set_grad_enabled(False)
device = t.device("mps" if t.backends.mps.is_available() else "cuda" if t.cuda.is_available() else "cpu")
dtype = t.bfloat16
import part1_emergent_misalignment.tests as tests
import part1_emergent_misalignment.utils as utils
from part1_emergent_misalignment.em_organism import LoraLayerComponents, get_all_checkpoint_components
from arena_lib.huggingface import GenerationProgress
from arena_lib.quant import has_native_bf16, quant_kwargs, set_4bit_compute_dtype
MAIN = __name__ == "__main__"
def print_with_wrap(s: str, width: int = 80):
"""Print text with line wrapping, preserving newlines."""
out = []
for line in s.splitlines(keepends=False):
out.append(textwrap.fill(line, width=width) if line.strip() else line)
print("\n".join(out))
This day needs an OpenRouter API key (OPENROUTER_API_KEY). On Colab, add it as a secret (see the System Requirements dropdown above). Anywhere else, put it in a file called .env at the top of the repo (ARENA_materials/.env):
OPENROUTER_API_KEY=your_openrouter_api_key_here
The setup cell at the top of the notebook loads it (and warns if it's missing), so re-run that cell after adding it.
A Hugging Face token (HF_TOKEN, set the same way) is optional: every model and checkpoint we download is public. Without one, the Hub prints a warning about unauthenticated requests, and downloads have lower rate limits.
# Setup OpenRouter client (works with both Claude and OpenAI models)
OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY")
assert OPENROUTER_API_KEY, "OPENROUTER_API_KEY isn't set: add it (see above), then re-run the setup cell at the top"
openrouter_client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key=OPENROUTER_API_KEY,
)