TL;DR
When a jailbreak tricks an LLM into writing something dangerous, the model usually isn’t genuinely fooled—its internal activations show it recognizes the harm as it types, even after its initial refusal mechanism failed. By mathematically "gluing" the model's internal concept of harmfulness directly to its refusal instinct across both the prompt and response phases, HARC achieves robust jailbreak defense without lobotomizing the model or making it paranoid about harmless questions.
What Problem Does This Paper Address?
Safety-aligned LLMs are famously fragile. Ask directly for a bomb recipe, and they politely decline; wrap the request in a clever persona or code completion task, and they happily oblige. Worse, heavy-handed defenses usually trigger an "alignment tax"—degrading general intelligence or causing over-refusal (e.g., refusing to explain how to "kill" a Linux process).
Recent mechanistic interpretability work showed that inside a model's residual stream (its main internal communication highway), "recognizing harm" ($v_{\text{harm}}$) and "deciding to refuse" ($v_{\text{ref}}$) are encoded as distinct linear directions—and in later layers, they become nearly orthogonal. Because they are separate, an adversarial prompt can trigger one without the other. Prior studies only looked at these signals while the model read the prompt. The authors ask a fascinating follow-up: when a jailbreak bypasses prompt-side defenses, does the model actually know it is generating harmful content while writing its response?
Methods
First, using standard difference-of-means extraction, the authors extend representational analysis from prompt tokens into the response tokens (pooling over the first 32 generated tokens). This yields a four-direction safety geometry: harmfulness and refusal vectors at both prompt and response positions.
To close the gap that jailbreaks exploit, they introduce HARC (Harmfulness-And-Refusal Coupling), a targeted LoRA fine-tuning method:
- Dual-Position Coupling Loss: Using an additive margin hinge loss on cosine projections, HARC forces both $v_{\text{harm}}$ and $v_{\text{ref}}$ to fire together on harmful inputs (and stay quiet on benign ones) at both prompt and response positions.
- Architecture-Agnostic Layer Selection: Rather than tuning layers by hand, HARC automatically scores and targets late layers where harm and refusal are maximally decoupled within a position, yet consistent across prompt and response.
- Dynamic Recomputation & Anchoring: Because LoRA updates shift the model's internal geometry during training, HARC periodically re-extracts the safety directions and smooths them via an Exponential Moving Average (EMA). Standard KL-divergence and cross-entropy terms keep general capabilities intact.
Because HARC operates strictly inside a tiny two-dimensional safety subspace, the rest of the model's computational machinery is left undisturbed.
Datasets
No new benchmarks are introduced; the paper relies on established datasets to isolate the effect of the coupling loss:
- Direction Extraction: 300 harmful prompts from AdvBench and 300 harmless prompts from UltraChat.
- Fine-Tuning: Harmful prompts and refusal continuations from the Circuit Breakers corpus, paired with UltraChat for benign examples (and PKU-SafeRLHF for DPO).
- Evaluation: Adversarial robustness on JailbreakBench (testing PAP, PAIR, CodeAttack, and DeepInception); over-refusal on XSTest and CoCoNot; and general capabilities across MMLU, GSM8K, HumanEval, IFEval, and MT-Bench.
Key Insights and Ideas
- The "Guilty Conscience" Effect: Even when a jailbreak completely suppresses harm recognition during prompt reading, the model's $v_{\text{harm}}^{\text{resp}}$ and $v_{\text{ref}}^{\text{resp}}$ signals roar back to life while it generates the harmful answer. In standard models, this realization simply arrives too late to halt the compliance trajectory.
- Jailbreaks Leave Distinct Geometric Fingerprints: Different attack styles exploit the harmfulness–refusal plane in neatly separable ways during prompt encoding. Persona framing (DAN) leaves harm recognition intact while muting refusal; semantic rewriting (PAIR) drives harmfulness negative; and code obfuscation (CodeAttack) suppresses both, masquerading as a benign prompt.
- Universal Safety Geometry: This four-direction structure isn't a quirk of Llama—it replicates cleanly across five distinct model families and scales from 7B up to 72B parameters at the exact same relative layer depths.
Key Results
Tested on Llama-3.1-8B and Qwen-2.5-7B against seven training- and inference-time baselines (including Circuit Breakers, RepBend, DPO, and CAST), HARC is the only method that improves safety without regressing on either helpfulness or over-refusal:
- Strong Robustness: HARC slashes average Attack Success Rate (ASR, graded 0–1 by GPT-4o) by 4.67× on Llama-3.1-8B (0.430 $\rightarrow$ 0.092) and 4.75× on Qwen-2.5-7B (0.632 $\rightarrow$ 0.133). Pairing HARC with DPO on Llama pushes average ASR down to 0.015 (0.000 on three of four attacks).
- Zero Alignment Tax: While baselines like RepBend achieve low ASR by refusing everything (100% over-refusal on Qwen XSTest), HARC actually undercuts the base models' over-refusal rates (dropping XSTest refusal from 0.109 $\rightarrow$ 0.035 on Llama, and 0.091 $\rightarrow$ 0.026 on Qwen) while matching baseline capability scores (0.670 vs. 0.668 on Llama; 0.717 vs. 0.714 on Qwen).
- Effortless Scaling: Applied to Llama-3.1-70B and Qwen-2.5-72B with zero hyperparameter retuning, HARC drives Llama-70B's ASR below 0.01 on PAIR, PAP, and DeepInception while preserving MMLU and GSM8K accuracy.
Limitations and Future Work
- Blind Spots to Deep Obfuscation: HARC binds existing harm signals to refusal; it doesn't invent new ones. Because CodeAttack wraps harmful requests in code structures absent from the natural-language training set, the model's representations stay clustered with benign inputs, leaving CodeAttack as the hardest residual vulnerability (0.290 ASR on Llama-8B). Expanding direction-extraction data to cover obfuscated formats is an immediate next step.
- Fragility to Weight-Space Attacks: Because HARC is a surgical, low-dimensional LoRA edit designed for black-box API defense, an attacker with direct weight access can undo it by fine-tuning on roughly 160 harmful examples.
- Future Horizons: The authors highlight defending against hypothetical attacks that erase harm recognition across both prompt and generation phases, testing adaptive attacks designed specifically to target HARC's coupled layers, and extending this four-direction analysis to multimodal vision-language models.
Summary updated