[1.3.1] Linear Probes
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 ~19 minColab🟧 Pro needed (L4)Download🟧 ~86 GBKeys🔑 Hugging Face
- 🖥️ GPU: 🟧 16 GiB (A4000). Peak ~14 GiB with
LOW_GPU_MEM(auto below 30 GiB: 13B and 8B in 8-bit, 70B bonus in 4-bit); ~27 GiB without. - ⏱️ Runtime (ex. downloads/API): GPU ~19 min · CPU N/A
- ☁️ Colab? 🟧 Pro needed (L4): RAM peaks at ~13 GB (free Colab has 12.7) and the downloads are more than free Colab's disk; with the float16 fallback the day takes 37 min on a T4. L4: 20 min
- 💾 Downloads: 🟧 ~86 GB: meta-llama/Llama-3.3-70B-Instruct (first 24 of 80 layers, for the 70B section) 43 GB, meta-llama/Llama-2-13b-hf 26 GB, meta-llama/Meta-Llama-3.1-8B-Instruct 16 GB
- 🔑 API keys:
- 🟥 Mandatory: Hugging Face (
HF_TOKEN), for the Llama models (request access:meta-llama/Llama-2-13b-hf,meta-llama/Llama-3.1-8B-Instruct,meta-llama/Llama-3.3-70B-Instruct(bonus)) - 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 (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: Hugging Face (
- 🐏 RAM: ~13 GB at peak
GPU times measured on a 16 GB RTX A4000. Compare every day →
Introduction
This exercise set is built around linear probing, one of the most important tools in mechanistic interpretability for understanding what information language models represent internally.
We'll look at three papers:
- The Geometry of Truth paper by Marks & Tegmark, which shows that LLMs develop linear representations of truth that generalize across diverse datasets and are causally implicated in model outputs.
- The deception probes paper from Apollo Research, which extends this from factual truth to strategic deception detection - showing probes trained on simple contrastive data can generalize to realistic deception scenarios.
- The high-stakes interactions paper (NeurIPS 2025), which trains attention probes to detect whether a user's request is high-stakes - a different target from model intent - and shows they match full LLM classifiers at a fraction of the compute cost.
What is probing?
The core idea: extract internal activations from a model, then train a simple classifier on them. If a linear probe can accurately classify some property from the activations, that property is linearly represented in the model's internal state.
From the Geometry of Truth paper:
"We identify a linear representation of truth that generalizes across several structurally and topically diverse datasets... these representations are not merely associated with truth, but are also causally implicated in the model's output."
The "causally implicated" part matters a lot: it's not just that we can read off truth from model internals, but that the model actually uses these representations when computing outputs. We'll verify this in Section 3.
Why this matters for safety
If we can reliably detect truth, deception, or intent from model internals, there are direct implications for model monitoring. Neel Nanda argues probes could even be used during training:
"There are certain things that may be much easier to specify using the internals of the model. For example: Did it do something for the right reasons? Did it only act this way because it knew it was being trained or watched?"
But this is genuinely controversial. The worry, as Bronson Schoen puts it, is that training against probe signals might just teach the model to hide whatever the probe was measuring:
"If you train directly against non-obfuscated internals and no longer see bad behavior, the obvious possibility is that now you've just got obfuscated internals."
For deception probes specifically, the generalization question is especially pointed: we may need to detect sophisticated deception in scenarios we've never seen. As the Apollo paper puts it: "our monitors will need to exhibit generalization - correctly identifying deceptive text in new types of scenarios."
What you'll build
These exercises cover the full pipeline: extracting activations, visualizing with PCA, training probes, validating them causally, and applying them to deception detection. Layer choice, token position, and probe type all matter - part of the point is developing intuition for why.
Models we'll use
Sections 1-3 use meta-llama/Llama-2-13b-hf (base model, ~26GB in bfloat16). The Geometry of Truth paper has specific configurations for this model (probe_layer=14, intervene_layer=8), so our results should closely match theirs. Section 4 switches to meta-llama/Meta-Llama-3.1-8B-Instruct (instruct-tuned, ~16GB), needed for the deception detection instructed-pairs methodology.
Both fit comfortably on a single A100. As a bonus, we also run the paper's own probe on Llama-3.3-70B-Instruct (the scale of its strongest results), loading only the layers that probe needs so it still fits on one GPU.
GPU memory requirements
These bfloat16 models need a GPU with about 32GB. On a GPU with less than 30 GiB, the variable LOW_GPU_MEM is set to True automatically, and we load Llama-2-13B and Llama-3.1-8B with 8-bit weights (bitsandbytes load_in_8bit, about 13GB and 9GB), and the 70B bonus with 4-bit (nf4) weights instead of 8-bit. Section 5 only reads layer 16, so whenever it loads its own copy of Llama-3.1-8B (always with LOW_GPU_MEM, where section 4's copy is 8-bit) it loads just the first layers, in bfloat16, so its activations are exactly the same.
GPUs older than NVIDIA's RTX 30-series (like Colab's T4) have no native bfloat16 support: PyTorch only emulates it there, which is slow. On those GPUs dtype is set to float16 instead of bfloat16 (by half_dtype from arena_lib/quant.py), and you'll see a warning saying so. Wherever this page says bfloat16, read float16 in that case. float16 has a much smaller range than bfloat16 (it overflows above 65504), which these models stay within, and your numbers can differ from the reference outputs in the second or third decimal place.
Content & Learning Objectives
1️⃣ Setup & visualizing truth representations
Learning Objectives
- Extract hidden state activations from specified layers and token positions
- Implement PCA to visualize high-dimensional activations
- Observe that truth is linearly separable in activation space - even without supervision
- Understand which layers best represent truth via a layer sweep
2️⃣ Training & comparing probes
Learning Objectives
- Implement difference-of-means (MM) and logistic regression (LR) probes
- Compare probe types: accuracy, direction similarity, and what each captures
- Understand CCS (Contrastive Consistent Search) as an unsupervised alternative and its limitations
3️⃣ Causal interventions
Learning Objectives
- Understand why classification accuracy alone is insufficient - causal evidence is needed
- Implement activation patching with probe directions to flip model predictions
- Compare the causal effects of MM vs. LR probe directions
- Appreciate that MM probes find more causally implicated directions despite lower classification accuracy
4️⃣ Probing for Deception
Learning Objectives
- Construct instructed-pairs datasets following the deception-detection paper's methodology
- Train deception probes on instruct-tuned models
- Evaluate whether deception probes generalize to factual truth/falsehood datasets
- Understand methodological choices that affect replicability
5️⃣ Attention Probes for High-Stakes Detection
Learning Objectives
- Understand what "high-stakes interactions" means as a probe target, and why it differs from probing model intent
- Extract full-sequence activations (shape
(n, seq, d_model)) rather than last-token only- Implement an attention probe as a
nn.Module- a single learned query that computes a weighted sum over token positions before classification- Compare attention pooling against last-token and mean-pool baselines using AUROC
- Inspect learned attention weights to understand which parts of a prompt are most diagnostic
Reading Material
The core papers we'll be replicating are "The Geometry of Truth" and "Detecting Strategic Deception Using Linear Probes" - you should at least skim both before starting, so you understand the basics. The other references give you more context on the probing literature and the open questions around it.
- The Geometry of Truth: Emergent Linear Structure in Large Language Model Representations of True/False Datasets by Marks & Tegmark (COLM 2024). Shows that LLMs develop linear representations of truth that generalise across diverse datasets and are causally implicated in model outputs. Read at least the abstract, and sections 1, 2 & 4 (intro, datasets & visualization). You can skip 3, because we won't be doing much of this kind of patching in these exercises.
- Detecting Strategic Deception Using Linear Probes by Goldowsky-Dill et al. (Apollo Research, 2025). Extends truth probing to strategic deception detection, showing that probes trained on simple contrastive data can generalise to realistic deception scenarios. Section 4 of this exercise set replicates their methodology. Read the abstract and sections 1 & 3 (introduction and methodology).
- Detecting High-Stakes Interactions with Activation Probes by McKenzie et al. (NeurIPS 2025). Trains attention probes to detect whether a user's request is high-stakes, matching full LLM classifiers at much lower cost. Section 5 of this exercise set replicates this. Read the abstract and section 2 (methodology), or alternatively just the EleutherAI post.
- Discovering Latent Knowledge in Language Models Without Supervision by Burns et al. (ICLR 2023). Introduces Contrastive Consistent Search (CCS), an unsupervised method for finding truth directions without labelled data. We discuss CCS limitations in section 2 but don't implement it in full. Optional reading.
Setup code
The setup code downloads the few data files we need from the Geometry of Truth and Deception Detection repos. They're mirrored on HuggingFace at arena-education/geometry-of-truth and arena-education/deception-detection, with the same file paths as the original repos.
Llama-2-13b-hf and is a gated model, so you'll need a HuggingFace access token (as well as requesting access here, you might also want to request access to Llama-3.1-8b-Instruct and Llama-3.3-70b-Instruct while you're at it, since you'll need those models later in the exercises). When you've got access and made a HuggingFace token with read access, add it as HF_TOKEN: on Colab as a secret (see the System Requirements dropdown above), anywhere else in a file called .env at the top of the repo (ARENA_materials/.env):
HF_TOKEN=hf_your_token_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. The code below uses this token for authentication.
import arena_lib
exercises_dir, section_dir = arena_lib.setup("1.3.1")
import gc
import json
import os
import pickle
from dataclasses import dataclass
from pathlib import Path
import circuitsvis as cv
import einops
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
import torch as t
from datasets import load_dataset
from huggingface_hub import snapshot_download
from IPython.display import HTML, display
from jaxtyping import Bool, Float, Int
from plotly.subplots import make_subplots
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_auc_score, roc_curve
from sklearn.preprocessing import StandardScaler
from torch import Tensor
from tqdm.auto import tqdm
from transformers import AutoModel, AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
# Grow GPU memory blocks instead of caching many fixed-size ones: less fragmentation, so the day fits a 16GB GPU
os.environ.setdefault("PYTORCH_CUDA_ALLOC_CONF", "expandable_segments:True")
device = t.device("cuda" if t.cuda.is_available() else "cpu")
# LOW_GPU_MEM fires automatically on GPUs with less than 30 GiB (e.g. Colab's 16GB T4), or with no CUDA GPU at all.
LOW_GPU_MEM = not t.cuda.is_available() or t.cuda.get_device_properties(0).total_memory / (1024**3) < 30
import part31_linear_probes.tests as tests
import part31_linear_probes.utils as utils
from arena_lib.huggingface import get_act_name, run_with_cache
from arena_lib.quant import half_dtype, silence_int8_cast_warning
dtype = half_dtype() # bfloat16, or float16 (with a warning) on GPUs without native bfloat16, like Colab's T4
silence_int8_cast_warning() # 8-bit layers log a line per forward pass when the model is bfloat16
MAIN = __name__ == "__main__"
# HF mirrors of the files we use from each repo (same paths as the originals)
GOT_ROOT = Path(snapshot_download("arena-education/geometry-of-truth", repo_type="dataset"))
DD_ROOT = Path(snapshot_download("arena-education/deception-detection", repo_type="dataset"))
GOT_DATASETS = GOT_ROOT / "datasets"
DD_DATA = DD_ROOT / "data"
Loading the model
We start with LLaMA-2-13B, a base (not instruction-tuned) model. The Geometry of Truth paper uses this model with probe_layer=14 and intervene_layer=8 - we'll use these exact values.
HF_TOKEN = os.getenv("HF_TOKEN")
assert HF_TOKEN, "HF_TOKEN isn't set: add it (see above), then re-run the setup cell at the top"
MODEL_NAME = "meta-llama/Llama-2-13b-hf"
print(f"{LOW_GPU_MEM=}")
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = AutoModelForCausalLM.from_pretrained(
MODEL_NAME,
dtype=dtype,
device_map="cuda" if LOW_GPU_MEM else "auto", # on 16GB, "auto" would offload some of the 8-bit model to the CPU
# 26GB in bf16; threshold 2 (default 6) keeps more outliers in 16-bit, so results stay closer to bf16
quantization_config=BitsAndBytesConfig(load_in_8bit=True, llm_int8_threshold=2.0) if LOW_GPU_MEM else None,
)
tokenizer.pad_token = tokenizer.eos_token
tokenizer.padding_side = "right"
NUM_LAYERS = len(model.model.layers)
D_MODEL = model.config.hidden_size
# Layer choices from the geometry-of-truth repo config for llama-2-13b. The paper
# found truth representations are concentrated in early-to-mid layers, and identified
# these specific layers via patching experiments (Section 3, "group (b)").
PROBE_LAYER = 14
INTERVENE_LAYER = 8
print(f"Model: {MODEL_NAME}")
print(f"Layers: {NUM_LAYERS}, Hidden dim: {D_MODEL}")
print(f"Probe layer: {PROBE_LAYER}, Intervene layer: {INTERVENE_LAYER}")
Loading the datasets
The Geometry of Truth paper uses several carefully curated datasets of simple true/false statements. Each dataset has a statement column and a label column (1=true, 0=false).
From the paper:
"We find that the truth-related structure in LLM representations is much cleaner for our curated datasets than for our unstructured ones."
Let's load three of these curated datasets and examine them:
DATASET_NAMES = ["cities", "sp_en_trans", "larger_than"]
datasets = {}
for name in DATASET_NAMES:
df = pd.read_csv(GOT_DATASETS / f"{name}.csv")
datasets[name] = df
print(f"\n{name}: {len(df)} statements ({df['label'].sum()} true, {(1 - df['label']).sum():.0f} false)")
display(df.head(4))