Abstract
Large Language Models (LLMs) have emerged as powerful tools, but their inherent safety risks—ranging from harmful content generation to broader societal harms—pose significant challenges. These risks can be amplified by recent adversarial attacks, fine-tuning vulnerabilities, and the increasing deployment of LLMs in high-stakes environments. Existing safety-enhancing techniques, such as fine-tuning with human feedback or adversarial training, are still vulnerable as they address specific threats and often fail to generalize across unseen attacks, or require manual system-level defenses. This paper introduces RepBend, a novel approach that fundamentally disrupts the representations underlying harmful behaviors in LLMs, offering a scalable solution to enhance (potentially inherent) safety. RepBend brings the idea of activation steering—simple vector arithmetic for steering model's behavior during inference—to loss-based fine-tuning. Through extensive evaluation, RepBend achieves state-of-the-art performance, outperforming prior methods such as Circuit Breaker, RMU, and NPO, with up to 95% reduction in attack success rates across diverse jailbreak benchmarks, all with negligible reduction in model usability and general capabilities.
Introduction
Standard safety training for LLMs, including Reinforcement Learning from Human Feedback (RLHF) and Direct Preference Optimization (DPO), often results in what researchers call "shallow safety alignment." While these models learn to generate refusal strings like "I cannot help with that," their internal representations of harmful knowledge remain largely intact. Adversarial attacks, or "jailbreaks," exploit this by finding pathways in the model's activation space that bypass the safety layer, effectively accessing the underlying harmful capabilities.
Furthermore, existing defenses often face a "safety-utility trade-off." Increasing a model's robustness frequently leads to "over-refusal," where the model rejects harmless prompts (e.g., "how to kill a computer process") or suffers a decline in general reasoning and coding abilities. RepBend addresses these challenges by fundamentally "bending" the model's internal activation space to ensure that harmful concepts are not just suppressed at the output level, but disrupted at the representational level.
Methodology: Representation Bending
RepBend integrates the intuition of activation steering—traditionally a technique used during inference to nudge model behavior via vector arithmetic—directly into the fine-tuning process. Instead of optimizing solely on token sequences, RepBend optimizes the model's internal hidden states using Low-Rank Adaptation (LoRA).
The Four-Part Loss Function
The core of the RepBend algorithm is a composite loss function designed to reshape the activation space:
- Retain Loss ($L_2$): This term minimizes the change in activations for safe prompts, ensuring the model preserves its original, helpful behavior.
- Forget/Push Loss ($L_2$): This maximizes the distance between the original and tuned activations for unsafe prompts, effectively "pushing" harmful representations away from their functional states.
- Cosine Similarity Loss: This encourages all harmful prompts to align toward a consistent, predefined "refusal" direction in the vector space, making the safety boundary more uniform.
- KL Divergence: This ensures the model’s output distribution for safe prompts remains close to the original base model, preserving general intelligence and linguistic fluency.
Research indicates that this "bending" is most effective when applied to mid-to-later layers (e.g., layer 20 and beyond in a 32-layer model), where the model begins to cluster behavioral intent rather than just processing raw syntax.
Experimental Evaluation
Datasets and Benchmarks
The authors trained RepBend using a curated dataset of 30,000 samples from WildGuardMix, WildJailbreak, and UltraChat, providing a balanced mix of harmful, harmless, and general instruction-following data. Safety was evaluated against rigorous benchmarks including HarmBench, TrustLLM-Jailbreak, and adversarial optimization attacks like GCG (Greedy Coordinate Gradient). General capabilities were measured across eight benchmarks, including MMLU (knowledge), GSM8K (math), and HumanEval (coding).
Key Results
- State-of-the-Art Safety: RepBend achieved a 3.25% Average Attack Success Rate (ASR) on Mistral 7B, a significant improvement over prior methods like Circuit Breaker (19.19%) and NPO (5.83%).
- Preserved Utility: On the MMLU benchmark, a Llama 3 8B model tuned with RepBend scored 65.08, nearly identical to the original model's score of 65.89.
- White-Box Robustness: Even when attackers had full access to model weights (white-box scenarios), RepBend maintained an ASR of approximately 3%, whereas competing methods often saw success rates jump to 10-25%.
- Cross-Architecture Scalability: The method proved effective across various architectures, including Gemma 2 2B and Qwen 2.5 14B.
Internal Mechanics and Insights
The "Safety Basin"
The study found that RepBend is relatively insensitive to the exact weighting of the cosine similarity term. This suggests the existence of a robust "safety basin" where the model remains aligned even under small perturbations, contributing to its resilience against novel attacks.
Breaking Internal Logic
Using Logit Lens—a technique to visualize the model's "thoughts" at each layer—the researchers observed that when a RepBend-tuned model is forced to generate a harmful response (e.g., via prefilling attacks), its internal representations diverge into high-entropy, garbled tokens. The model does not just refuse; it effectively loses the internal coherence required to construct the harmful thought.
Representational Separation
Principal Component Analysis (PCA) plots reveal that before RepBend, safe and unsafe activations are often intertwined in the vector space. After applying RepBend, these activations are pushed into distinct, non-overlapping clusters. This separation makes it significantly harder for an adversarial attack to "nudge" a safe activation into a harmful one.
Conclusion and Future Work
RepBend represents a shift from surface-level safety filters to deep representational alignment. While highly effective, the method faces certain limitations: like all unlearning-based approaches, models can potentially "re-learn" harmful behaviors if later fine-tuned on large amounts of malicious data. Additionally, in rare instances, the model may output gibberish rather than a standard refusal. Future research will focus on "safe post-tuning" to prevent re-learning and refining the refusal outputs to be more user-friendly while maintaining the underlying representational disruption.
Summary updated