IN THIS BREAKDOWN · 10 SECTIONS
You can read 18% of this breakdown.
The paper in one minute
A few-shot jailbreak shows a model a handful of fake dialogues in which the assistant happily answers requests it should refuse, then asks the real question. With short context windows, that doesn't work on aligned models. By 2024 context windows held hundreds of thousands of tokens, so the authors asked what happens with hundreds of fake dialogues instead of a handful.
Many-shot jailbreaking (MSJ) builds one long prompt from compliant question-answer pairs (generated with a model that had no harmlessness training), formatted as user and assistant turns, followed by the target question. It needs control over the dialogue history, which an API gives and consumer chat apps generally don't.
On Claude 2.0 the attack didn't work at 5 shots and worked consistently at 256. It worked on GPT-3.5, GPT-4, Llama 2 70B and Mistral 7B too, with about 128 shots enough for all of them on one evaluation. Attacks of about 70,000 tokens showed no plateau.
The key result is the shape. The negative log-likelihood of a harmful reply falls as a power law in the number of shots, the same shape as in-context learning on harmless tasks. Changing the prompt format, or running standard supervised and RL alignment training, moved the curve's intercept but not its slope, so a long enough attack still won. Training specifically on many-shot examples didn't change the slope either. What helped most was a prompt-level defense: wrapping the input in a cautionary warning cut one attack from 61% to 2%.
Research notes: the problem, approach and results
shots enough for all five tested models to adopt the harmful behavior on malevolent-personality evaluations
attack success at 205 shots with a cautionary warning wrapped around the prompt; in-context refusal examples only reached 54%
128-shot attack success on Claude 2.0 in an independent HarmBench replication, against 2% for the best earlier attack
Context windows grew from about 4,000 tokens to millions in 2023, and nobody had measured what an attacker could do with that much room.
Many-shot jailbreaking (MSJ): put hundreds of fake user-assistant exchanges in one prompt, where the assistant answers requests it should refuse, then ask the real question. Measure how the likelihood of a harmful reply scales with the number of shots.
MSJ worked on Claude 2.0, GPT-3.5, GPT-4, Llama 2 70B and Mistral 7B, with about 128 shots enough on all of them. Effectiveness followed a power law; supervised and RL alignment training raised the intercept but not the exponent, while a simple cautionary-warning prompt cut one attack from 61% to 2%.
Why it matters to an FDE
Every increase in context capacity you ship is also a security change. This paper is the clearest evidence for that.
Long context is an input channel. Conversation history, retrieved documents, uploaded files and remembered facts all count as context. If someone controls enough of it, they can steer behavior the model would refuse in a short prompt.
Test at the lengths you deploy. Safety evaluations on short, isolated prompts can pass while the same model fails at 50,000 tokens. The paper's power-law fit gives a way to forecast the length at which an attack starts working from cheaper short-context measurements.
Product limits are defenses. Caps on context length, how much history is kept, how many documents are retrieved, and who may supply the dialogue history all bound the number of shots an attacker gets. For a personal assistant, accumulated history and memory are part of the security design.
Understand the mechanism. Try it on a real problem.
Unlock this breakdown and 157 more papers.
Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.
6 months · One payment · No auto-renewal
- ◇1 architecture diagram
- </>1 runnable code experiment
- ▦2 results tables
- ?5 interview questions with answers
- 03Key takeaways
The scaling law, its two parameters, what moves each one, and three misreadings
Free account - 04How it works
The attack string, log-likelihood measurement, the fitted law, the mitigation experiments
Premium - 05The numbers that matter
Shot counts, lengths, models, the defense results and the HarmBench replication
Premium - 06Try it yourself
Fit the power law, forecast attack length, and compare intercept, slope and context-cap defenses
Premium - 07Where it breaks
Model vintage, the API-access assumption, untested defense costs, judge reliance and slips
Premium - 08Using it on a deployment
Context-length security tests, product limits, provenance of history and memory, prompt wrappers
Premium - 09Interview angles
Five questions this paper prepares you for, with answer hints
Premium - 10Read next
Where to go from here on this site
Premium
