TL;DR
When you stream text from an LLM token-by-token, traditional post-generation safety filters act too late to stop harmful content from flashing across a user's screen, while heavy input guardrails ruin real-time responsiveness. JEDI solves this by acting like a real-time thermostat inside the model’s hidden layers: it tracks subtle semantic drift toward harmful compliance as tokens are generated and dynamically nudges the model back toward a polite refusal only when persistent danger accumulates. It blocks over 95% of jailbreak attacks while adding just 3 milliseconds to the time it takes for the first word to appear.
What Problem Does This Paper Address?
Modern LLM interfaces stream responses word-by-word so users aren't left staring at a blank screen. However, streaming introduces a glaring vulnerability called prefix exposure: if an attacker "jailbreaks" the model into bypassing its safety training, dangerous tokens spill onto the user's screen immediately.
Existing defenses struggle with a three-way tug-of-war between safety, utility, and latency:
- Post-generation filters wait until the full answer is written to moderate it—meaning the user has already seen (or scraped) the harmful prefix.
- Pre-generation defenses (like external guardrail models or input-perturbation techniques) inspect or scramble prompts beforehand, adding seconds of lag to the Time To First Token (TTFT).
- Static in-generation steering alters internal activations on the fly, which can prevent leaks, but single-token signals are noisy—leading to "over-refusal" where the model rejects harmless questions that merely sound edgy.
Methods
While extracting linear directions in activation space ("representation engineering") is an established technique, JEDI’s novelty lies in pairing a separate internal sensor and actuator inside a real-time, trajectory-conditioned control loop.
JEDI operates in two stages:
- Offline Vector Extraction: Because raw LLM hidden states are anisotropic (dominated by a few high-variance directions), the authors first standardize ("whiten") the space using benign activations. Using contrastive prompt-prefix pairs, they extract two directions at the model's most discriminative layer:
- A Condition Vector ($c_l$)—the sensor—pointing toward harmful content generation.
- An Intervention Vector ($v_l$)—the actuator—pointing from compliance toward refusal. Crucially, they make $v_l$ mathematically orthogonal to $c_l$ (via Gram–Schmidt) so that steering toward refusal doesn't accidentally lobotomize general instruction-following.
- Online Defense: During live streaming, each new token's hidden state is projected onto $c_l$ and ReLU-rectified to filter out baseline noise. Rather than panicking at a single noisy spike, JEDI feeds these scores into a Cumulative Sum (CUSUM) sequential drift detector. Only when accumulated evidence crosses an alarm threshold does JEDI inject $v_l$ into the hidden states—using a power-law scaling factor so that mild drifts get a gentle tap on the wheel and severe jailbreaks get a hard turn toward refusal. Once risk subsides, the steering naturally decays.
Datasets
The authors do not introduce new benchmarks, instead assembling disjoint existing datasets for calibration and testing:
- Offline Calibration ($D_{\text{cal}}$): 100 harmful prompts from HarmBench (generated via GCG, PAIR, AutoDAN, and TAP) and 100 benign prompts from JustEval, paired with 100 compliance/refusal prefixes to create 10,000 contrastive samples. Another 200 prompts ($D_{\text{sep}}$) test layer separability.
- Safety Evaluation: 1,100 transfer jailbreak prompts from PandaGuard spanning 11 attack methods (7 of which are completely unseen during calibration).
- Utility & Over-Refusal: AlpacaEval (general helpfulness), XSTest (benign prompts that look superficially harmful), and OR-Bench (targeted over-refusal testing).
Key Insights and Ideas
- Accumulating evidence beats reacting to spikes: LLMs experience stochastic token-level fluctuations even during safe chats. Replacing JEDI's CUSUM accumulator with instantaneous single-token triggers drops the defense success rate by 14 to 21 percentage points at the same false-alarm rate.
- Decoupling detection from steering saves utility: Making the refusal vector orthogonal to the harm-detection vector prevents the defense from trampling over benign instruction-following—without orthogonalization, compliance on tricky safe queries (XSTest) drops by 9.6 percentage points.
- Proportional steering matters: Fixing the intervention strength to a static constant ($\beta = 1$) instead of scaling it dynamically with the severity of the drift causes defense success to plummet by 28 to 38 percentage points.
Key Results
Evaluated across 6 open-source LLMs (Vicuna 7B/13B, Mistral 7B, Qwen2.5 7B/14B, and Qwen3-8B) and 11 jailbreak attacks:
- High Full-Response Safety: JEDI achieves a 95.7% mean Defense Success Rate (ranging from 93.6% to 99.4% across models), outperforming pre-, in-, and post-generation baselines like Activation Probe (90.4%), Gradient Cuff (75.8%), and SafeDecoding (74.2%).
- Prefix Exposure Reduction: On 3,975 streaming cases guaranteed to start with an unsafe prefix when undefended, JEDI slashes raw visible-onset frequency from 100% down to 26.61% (with only 6.30% resulting in a harmful final response).
- Near-Zero First-Token Lag & Preserved Utility: JEDI adds just 0.003 seconds to average TTFT (0.024s vs. 0.021s undefended, whereas multi-pass defenses take 3.6s to 50s), while keeping a 77.18% AlpacaEval Win Rate and 91.1% XSTest Compliance Rate.
Limitations and Future Work
- White-Box Access Required: JEDI needs read/write access to internal hidden states and decoding control, targeting self-hosted deployments or model developers rather than closed, proprietary APIs.
- Total Decoding Overhead & Scale: While TTFT overhead is tiny (3ms), per-token monitoring increases total response generation time from 7.98s to 8.89s on a single H100 GPU, and concurrent batched-serving throughput was not tested. Experiments are also limited to 7B–14B instruction-tuned models.
- Evasion & Calibration Scope: Offline calibration relies on only 200 unique base prompts. Furthermore, camouflaged trajectories can still slip past detection, and partial-information adaptive attacks slightly reduce JEDI's defense rate (by 1–4 percentage points). Expanding calibration sets, testing fully informed adaptive attacks, and exploring proxy deployments remain open for future work.
Summary updated