TL;DR
Batch prompting—a popular technique used to reduce LLM inference costs by bundling multiple queries into a single prompt—unwittingly creates a severe safety vulnerability. This paper demonstrates that mixing a single harmful request into a batch of benign questions consistently bypasses safety filters across both open-source and frontier commercial models. Fortunately, the authors show this vulnerability can be effectively neutralized using batch-aware Direct Preference Optimization (DPO).
What Problem Does This Paper Address?
As large language models (LLMs) are deployed at scale, reducing inference costs is a top priority for engineers. "Batch prompting" achieves this by packing multiple independent user queries into a single prompt, allowing them to share the computational overhead of system instructions or few-shot examples.
While excellent for efficiency, its safety implications have been dangerously overlooked. Standard safety alignment typically trains and evaluates models on single-question inputs. This paper exposes a critical blind spot: when a harmful question is processed alongside benign ones, the model's safety guardrails collapse. The authors prove that this "batch jailbreak" is a distinct failure mode, independent of known vulnerabilities like in-context learning (which requires malicious demonstrations) or long-context effects (which rely on massive, semantically related text blocks).
Methods
The authors analyze this safety failure from two complementary perspectives and propose a targeted defense:
- Alignment Signal Weakening (Reward Perspective): The authors evaluated how reward models score batched responses. They discovered that as the batch size grows, the "reward gap" between a safe response (refusing the harmful query) and a jailbroken response (complying with all queries) shrinks dramatically. Eventually, compliance is rewarded more than refusal.
- Refusal Signal Dilution (Representation Perspective): Using Principal Component Analysis (PCA) and linear probing, the authors tracked the model's internal hidden states. As more harmless questions are added to a batch, the entire prompt's representation shifts closer to the "benign" cluster, effectively diluting the internal refusal signal required to trigger a safety block.
- Batch-Aware Alignment: To fix this, the authors introduced a defense using Direct Preference Optimization (DPO). By training models on a small dataset of batch-structured inputs—where the preferred response is to selectively refuse only the harmful query while answering the rest—they successfully restored the models' safety margins.
Datasets
The paper evaluates the attack and defense using several established benchmarks:
- Harmful Queries: JailbreakBench (100 harmful questions) and StrongREJECT (313 harmful questions).
- Benign Queries: GSM8K (grade-school math), Alpaca (instruction following), and CoinFlip (symbolic reasoning) were used to construct the harmless background text for the batches.
- Defense Training: A dataset of 500 harmful question-answer pairs from BeaverTails, mixed with benign pairs from Alpaca, formatted into 5-query batches.
Key Insights and Ideas
- Unrelated Text is More Dangerous: Counterintuitively, mixing a harmful question with completely unrelated benign questions (like math problems) dilutes the refusal signal and triggers jailbreaks more effectively than using semantically related questions. This lowers the effort required by an attacker.
- "First is Worst" Position: Placing the harmful question at the very beginning of the batch yields the highest attack success rate. This allows an attacker to get the malicious answer immediately without waiting for the rest of the batch to generate.
- External Guardrails are Blind to Batches: Standard input moderation APIs (such as OpenAI Moderation, Llama Guard, and Azure AI Content Safety) become significantly less effective at detecting harmful intent as the batch size increases, proving that model-level alignment is necessary.
Key Results
- Frontier Models are Highly Vulnerable: While existing black-box attacks fail against commercial giants like GPT-5.3-Chat and Claude-4.6-Sonnet (resulting in near 0% attack success rates), batch prompting achieves a staggering 52.0% ASR on GPT and 66.0% ASR on Claude on JailbreakBench.
- Consistent Open-Source Failures: Across open-source models like Llama-3.1-8B, Phi-4-14B, and Qwen-3-8B, batch prompting consistently outperforms baseline attacks, achieving an average success rate of over 62%.
- DPO Successfully Defends the Model: Applying batch-aware DPO completely neutralizes the vulnerability, reducing the attack success rate to under 1% while fully preserving the model's performance on benign tasks.
Limitations and Future Work
- Proxy Reward Models: The training-perspective analysis relies on open-source reward models as proxies, which may not perfectly capture the proprietary internal alignment signals of commercial models like GPT or Claude.
- Simple Attack Structure: This study focuses on a basic, single-step black-box attack. The authors note that combining batch prompting with other jailbreak techniques (like adversarial suffixes or code obfuscation) could create even more potent, adaptive attacks. Investigating defenses against these hybrid methods is left for future work.
Summary updated