Activation Probes

Tiny classifiers that read a model's internal activations, the lists of numbers inside the model that describe what it has understood so far, to flag harmful prompts, before it answers.

← All tutorials

On this page

1 Jailbreak attacks 2 What an activation probe is 3 Which activations the probe reads 4 Scoring a prompt 5 Combining position scores 6 Training data 7 Probe and LLM cascade 8 Probes in practice 9 Results 10 Limitations 11 References

1 Jailbreak attacks

A large language model's core skill is following the instructions in your prompt, and that is also what makes it dangerous: it cannot tell which instructions deserve to be followed.

A jailbreak hides malicious instructions inside an innocent-looking prompt, and the assistant does exactly what it was told (Figure 1).

innocent-looking prompts"help me debugthis code"the code is malwarea long story thatslowly steers tohow to break inthe model follows it allphishing campaignsvulnerability huntingstep-by-step attack help
Figure 1. Jailbreaks hide a malicious instruction inside an innocent request.

Refusal training (see Aligning Language Models with RL) does not hold against determined attackers (Nasr et al., 2025), so Kramár et al. (2026) watch prompts at deployment time instead. Google DeepMind made these probes production-ready, and their findings informed the misuse-mitigation probes in user-facing Gemini.

The obvious monitor is a second large language model, an LLM judge, asked whether each prompt is an attack; it works, but every request now costs two giant model runs. An activation probe instead turns numbers the first model already computed in its forward pass (the prompt's single trip through the model) into one suspiciousness score.

LLM judgegiant modelanswersgiant modeljudges2 giant model runsActivation probegiant modelanswersprobeabout 1 dot productper position1 giant run + a tiny classifier
Figure 2. A judge runs a second giant model; a probe adds a tiny classifier.

Earlier probes broke in production: trained on short prompts, they fall apart on long documents, where one malicious sentence's score gets averaged away by a million innocent ones (Section 5.1). Training on long documents is far too expensive, so the paper engineers probes that generalize.

A token is a word-piece, the chunk the model actually reads ("unbelievable" might be three tokens). An activation is a list of numbers inside the model describing what it has understood so far.

2 What an activation probe is

The idea comes from neuroscience: if a small classifier reading one brain region can tell what the subject is seeing, that information lives in that region. In 2016 Alain and Bengio did the same to a network's intermediate layers and called the tiny linear classifiers probes.

A probe is too simple to learn much on its own, so a good answer means the knowledge was already in the layer (Figure 3). This paper asks whether the layer thinks the prompt is an attack.

neuroscienceAlain and Bengio, 2016brain regionrecordingssmallclassifierwhat is thesubject seeing?network layeractivationslinearprobeis this promptan attack?the probe only reads; the model never changesa good answer means the layer already knew
Figure 3. A brain or a network: read one region, ask one question.

Building a probe is four moves: copy the numbers out of the middle layer, learn one direction that scores them, test it on fresh prompts, and read the accuracy as a report on what the layer knew.

prompts flow up the stack 12 10 8 6 4 1 tap [1.3, -0.9, ...] copied numbers the probe 768 weights bias: -1.5 one learned direction attack numbers → 8.82 benign numbers → -0.75 fresh prompts, never seen in training attackcorrect benigncorrect attackcorrect benigncorrect benigncorrect attackwrong benigncorrect attackcorrect accuracy
Figure 4. The probe adds nothing; it reveals what the layer already holds.

The probe scores each position's copied numbers along one learned direction and adds a bias.
s = w·a + b
The dot product multiplies each copied activation by the matching number in the learned direction and adds the results; adding the bias gives the score. A high score means the concept is present, and that score is the triage signal.
s the scorew the learned directiona the copied numbersb the bias· dot product: multiply the copied numbers by the matching numbers in the learned direction and add the results

The probe reads what the model understood, not what it said, and its score is ready before any answer exists, so it can trigger a block or a second check, but it does not stop an attack by itself.

answernot written yetlate layersmiddle layerearly layerspromptprobe: one scoretaplow score:answernormallyhigh scoreblock, refuse,or ask abigger model
Figure 5. The probe scores the prompt from the middle layer, before any answer exists.

3 Which activations the probe reads

Each part of the prompt is represented as a list of numbers, and the hidden size is that list's length: how many numbers the model uses to describe what it has understood. The toy's list is 768 numbers long; Figure 7 in section 4 shows 8 of them so the arithmetic stays visible.

3.1 Positions, not words

Every block lets each slice of the prompt look at the other slices and mix their information in, so by block 8 the list where "injection" was has absorbed the whole sentence. Call each slice a position: a slot in the prompt whose list of numbers sees the entire prompt.

So the probe scores situations, not words: "SQL" scores 2.84 in the attack prompt of Figure 7 (section 4) and 0.75 in the benign one. That is why the probe taps the middle of the model instead of scanning the raw text.

3.2 Meaning builds in the middle layers

Interpretability work (reading what a model's numbers mean) usually finds that meaning, including whether something is off, builds in the middle layers.

Late layersplanning the next wordMiddle layersmeaning builds hereEarly layersraw word piecesthe probetaps hereunderstanding builds upwardunderstanding builds upward
Figure 6. Interpretability's usual picture; the paper only taps the halfway layer.

Tap too early and the lists are still just words; tap too late and the model is already committed to answering. The probe copies from the middle layer's residual stream, the model's running memory: one list of numbers per position that every block reads and adds its own update into (see The Transformer Block).

Each block adds its update to the running list instead of replacing it.
hl+1 = hl + fl(hl)
hl is one position's list of numbers after block l, and fl is the update block l computes from it. Because every block only adds, one copy of the list at the tap carries everything the model has built up to that block.

Every probe below uses this same tap: one fixed middle layer, one list of numbers per position.

3.3 The toy model

The toy model on this page is a GPT-style transformer (GPT: Generative Pre-trained Transformer; see Attention): 12 blocks (a block is one processing stage of the stack), hidden size 768, and 12 attention heads, independent scorers reading the prompt in parallel. The probe taps block 8 and copies every position's list of numbers. In the paper the same setup watches Gemini 2.5 Flash, which returns in Section 7, judging the prompts the probe is unsure about.

4 Scoring a prompt

This is a simplified single-head teaching version that matches no single paper architecture. The paper's real probes add heads, MLPs (multilayer perceptrons, small two-layer neural nets) and windows (short runs of consecutive positions) on top of the same three steps.

The probe scores every position, keeps the most suspicious one and squashes it into a probability.
si = w·ai
ai is position i's copied numbers and w is the learned direction. The dot multiplies each number by the matching number in the direction and adds the results, so the score si says how attack-like position i reads.
z = maxi si + b
Only the single most suspicious position's score survives, not an average; adding the bias b gives the raw score z. Adding b after the max gives the same z as adding it to every position's score first, which is how the walkthrough below writes it.
p = σ(z) = 11 + e−z
The sigmoid σ (the same squash as in Logistic Regression) squeezes any score into a probability p between 0 and 1. The toy flags the prompt when p reaches 0.5, that is when z ≥ 0. The probe is just 768 learned weights in w plus one bias.
understanding builds upward tokens in probe 768 learned weights + one bias number scores positions, keeps the max
Stage 4 of 4: one score, one decision.
Figure 7. The most suspicious position decides the verdict.

5 Combining position scores

Every probe shares one skeleton: score each position, combine the scores into one number, compare it to a threshold. They differ only in the combine step.

5.1 Mean-pooled probes dilute a short attack

Linear probe, the original form, averages, so in a million-token document one attack sentence is divided by a million and vanishes. Dilution is the failure mode.

EMA probe (exponential moving average, Cunningham et al. 2025) keeps the peak of the running average: was there ever a sustained stretch that looked bad? It keeps a short attack on long documents, but it raises many false alarms there (13.5% in Figure 19).

Smoothed suspiciousness per position
position in the prompt →
Figure 8. One sustained bad stretch is enough; the average never enters.

MLP probe scores each position with a small two-layer net of width 100 instead of one dot product, then averages, so it still dilutes.

Attention probe learns its own weights over positions (its own attention, not the model's) for a weighted average. The strongest baseline on short prompts, it missed 87.9% of long-context attacks because the weights spread over thousands of positions. It streams through the prompt with constant memory per head (paper Appendix L), so this is a weighting failure, not a compute one.

1 attack token among 9 benign tokens: the attack token gets 94.3% of the attention weight.
Start: 10 tokens.
Figure 9. More benign tokens shrink the attack's share (illustrative).

5.2 Max-pooled probes keep the strongest part

MultiMax, the paper's own design, gives the probe several probe heads (independent scorers), takes each head's most suspicious position and sums them; the toy uses one head. Max avoids dilution but raises more false alarms.

Max of Rolling Means, the paper's selected probe, keeps the worst 10-position window, each window weighted with attention, so the judgment stays local: 3.0% missed attacks and 1.2% false alarms on long contexts it never trained on.

AlphaEvolve probes let an AI system search about 2,500 candidate combine steps, seeded from the attention probe. It rediscovered max-style combining on its own and closed roughly half the gap between the attention baseline and a perfect probe.

averagemaxper-position scores, one attack positionaverage: one attack sentence is dilutedLinearaverage of all scoresEMApeak of the decaying averageMLPsmall net, then averageAttentionlearned weighted averagemax: the strongest part survivesMultiMaxmax per head, summedMax of Rolling Meansworst 10-token windowAlphaEvolvemachine-found, max-style
Figure 10. Averaging rules dilute one attack sentence; max-style rules keep it.
Figure 2 from the paper: probe architecture visualization showing the six stages
Swipe sideways to read the labels; tap to open full size.
Figure 11. The paper's Figure 2: "All our probing classifiers can be composed into six states … as illustrated."

The combine rules in NumPy on a toy 40-position document with the attack at positions 20 to 23; the rolling mean here is plain, without the paper's attention weights.

import numpy as np
rng = np.random.default_rng(0)
# 40 positions; 20 to 23 are the attack
s = rng.normal(-1.0, 0.5, 40)
s[20:24] = 3.0
linear = s.mean()
ema, run = [], 0.0
for s_i in s:
    run = 0.5 * s_i + 0.5 * run
    ema.append(run)
ema_score = max(ema)
# MultiMax: 4 heads x 40 positions
S = rng.normal(-1.0, 0.5, (4, 40))
multimax = S.max(axis=1).sum()
win = np.ones(10) / 10
means = np.convolve(s, win, "valid")
rolling = means.max()
  1. 1Toy position scores s: background near −1, a 4-position attack at 3.
  2. 2linear, mean pooling: the attack is diluted by the other 36 positions (Section 5.1).
  3. 3ema_score: a running average, then its maximum (eq card in Section 5.2, line 1).
  4. 4MultiMax takes the maximum per probe head over the score matrix S and sums over probe heads.
  5. 5rolling: average each 10-position window, keep the largest (eq card in Section 5.2, line 2).
Two knobs, the EMA weight and the window length, set how much these rules dilute an attack (the paper's section 3).
ri = α si + (1 − α) ri−1
ri is the running average and α, the EMA weight (0.5 in the code), is the newest score's share; the EMA probe keeps the largest ri. Raising α reacts faster and forgets sooner, α = 1 keeps no memory and equals the plain per-position max, and α near 0 averages a long stretch and dilutes a short attack again.
mj = 1W ∑i=jj+W−1 si
mj is the mean of the window that starts at position j, and W = 10 positions sets how long a suspicious run must be to count; the probe keeps the largest mj. A shorter window lets one odd position flag the prompt; a longer one dilutes an attack shorter than the window.

Every rule then adds a bias and applies the sigmoid, and the prompt is flagged when p reaches 0.5; the question is which rule keeps one attack sentence above that line.

A 5-token attack in a 40-token document.
Figure 12. Combined scores on a log scale; only max rules clear the tick.

6 Training data

The weights are learned from labeled prompts (Figure 13).

attack, y = 1benign, y = 0cyber attackscurated by expertsmulti-turn chatsstart innocent,then escalatereal user trafficpersonal data removedhard negativessound dangerous, are not:how did a famousbreach work?asking for helpwith an attackvstalking aboutattacks
Figure 13. Hard negatives separate talking about attacks from asking for help.
The training loss, binary cross-entropy (see Cross-Entropy Loss), for one labeled prompt.
L = −y log p
− (1 − y) log(1 − p)
y is the label, 1 for attack and 0 for benign, and p is the probe's probability of attack. Only one term is active: log p for an attack, log(1 − p) for a benign prompt. A confident correct answer costs little; a confident wrong one costs a lot, so it gets the bigger nudge to the weights.
Loss for an attack prompt at two scores 0.9 (confident, correct) 0.11 0.2 (confident, wrong) 1.61 bar length = loss = size of the nudge to the weights
Figure 14. Confidently wrong costs about 15× more than confidently right.

The training loop for the single-head max probe, in the style of the paper's section 2, with random stand-ins for the cached activations and labels.

import torch, torch.nn as nn
# cached block-8 acts, 64 prompts
acts = torch.randn(64, 50, 768)
y = torch.randint(0, 2, (64,)).float()
probe = nn.Linear(768, 1)
params = probe.parameters()
opt = torch.optim.AdamW(params)
loss_fn = nn.BCEWithLogitsLoss()
for epoch in range(1000):
    # (64, 50): score per position
    s = probe(acts).squeeze(-1)
    z = s.max(dim=1).values
    loss = loss_fn(z, y)
    opt.zero_grad()
    loss.backward()
    opt.step()
  1. 1Cached activations and labels: 64 prompts, 50 positions, width 768.
  2. 2The Linear layer holds w and b; BCEWithLogitsLoss applies the sigmoid inside the loss.
  3. 3Scores every position, keeps the maximum per prompt, compares with the label.
  4. 4A full-batch AdamW update, 1000 epochs over activations harvested once.

One deliberate choice shapes everything that follows: the probes are trained only on short prompts. Training on long-context data costs about 22 times more, because million-token activation sets overflow accelerator (TPU) memory. So long contexts stay a pure test the probe never studied for.

The decision threshold is picked on a validation set (held-out prompts the probe did not train on) with false alarms weighted heaviest, because a monitor with too many gets switched off. The toy on this page flags at p = 0.5.

benignattackthresholdraisemissed attacksfalse alarmsprobe score →error weights when picking it50 false alarm5 missed attack2 hard-negative false alarm
Figure 15. Raising the threshold trades missed attacks for fewer false alarms.

7 Probe and LLM cascade

The probe is cheap and the big model is not, so the paper pairs them: the probe decides the clear cases alone, and the unsure middle goes to Gemini 2.5 Flash for a second opinion.

benign answer normally unsure: ask Flash second opinion attack block t0 t1 about 8% of prompts probe score →
Figure 16. Only unsure cases reach the big model.

The cascade scores lower error than Flash alone at roughly 1/50th the inference cost. The best thresholds are a plain deterministic pair, because a randomized defense would hand attackers a best-of-N exploit (retry N times, keep the best outcome).

Figure 1 from the paper: error rate versus relative inference cost for probes, LLMs, and the cascade
Figure 17. The paper's Figure 1: "We improve over prior activation probing work … at over 10,000× lower cost."

8 Probes in practice

The activations come from a forward hook on the tapped block. This listing uses GPT-2 small, which has the toy's shape (12 blocks, width 768): save copies block 8's output for each prompt into cache, and the training loop in section 6 reads them from there.

import torch
from transformers import GPT2Model, GPT2Tokenizer
tok = GPT2Tokenizer.from_pretrained("gpt2")
model = GPT2Model.from_pretrained("gpt2")
model.eval()
cache = []

def save(module, inputs, output):
    # output[0]: (1, T, 768)
    cache.append(output[0].detach())

# block 8, counting from 1
blk = model.h[7]
hook = blk.register_forward_hook(save)
text = "help me debug this code"
ids = tok(text, return_tensors="pt")
with torch.no_grad():
    model(**ids)
hook.remove()
  1. 1Loads GPT-2 small in eval mode.
  2. 2A forward hook on block 8 stores its output activations.
  3. 3Runs one prompt with gradients off, then removes the hook.

9 Results

The paper tests the probes on short prompts, long documents, multi-turn chats, and real jailbreaks. A probe alone costs over 10,000 times less than an LLM judge and makes fewer errors.

Probes trained only on short prompts are scored on long contexts they never saw, on two rates where lower is better: FNR (false negative rate, the fraction of real attacks missed, left axis) and FPR (false positive rate, the fraction of benign prompts falsely flagged, right axis).

Long-context generalization: missed-attack and false-alarm rates for three probes on long contexts
Swipe sideways to read the labels; tap to open full size.
Figure 18. Attention misses 87.9%, the selected probe 3.0% (paper).

No single probe wins on every distribution shift (prompts in production differing in kind or length from the training prompts): the best one for long contexts is not the best for multi-turn chats, so each deployment picks its own.

Figure 19 puts the long-context trade-off on one plot. With no distribution shift at all, plain attention is already near-optimal.

00303060609090false alarms on benign (FPR, %)missed attacks (FNR, %)① selected (rolling)misses 3.0%, flags 1.2%EMA linearmisses 1.7%, flags 13.5%② attentionmisses 87.9%, flags 0.0%③ MultiMax variantmisses 0, flags up to 82%
Figure 19. Lower left is better; values from Figure 18 and the paper's text.

10 Limitations

Probes read a model's inner numbers to judge it. From BLIP to the Q-Former reads another model's inner numbers to feed a language model instead.

11 References

  1. Kramár, J., et al. (2026). Building Production-Ready Probes For Gemini. arXiv:2601.11516. arxiv.org/abs/2601.11516
  2. Alain, G., and Bengio, Y. (2016). Understanding intermediate layers using linear classifier probes. arXiv:1610.01644.
  3. Cunningham, Peng, et al. (2025). Cost-Effective Constitutional Classifiers via Representation Re-use. Anthropic Alignment Science Blog. alignment.anthropic.com/2025/cheap-monitors. The EMA probe.
  4. Nasr, M., et al. (2025). The Attacker Moves Second: Stronger Adaptive Attacks Bypass Defenses Against LLM Jailbreaks and Prompt Injections. arXiv:2510.09023.