Abstract
Large Language Models (LLMs) remain vulnerable to adversarial "jailbreaks" that bypass safety alignments. This paper introduces a defense framework based on Contrastive Representation Learning (CRL) using a triplet-based loss and adversarial hard negative mining. This approach "breaks" the model's internal representations for harmful queries, forcing incoherent outputs rather than dangerous information. Evaluated on Llama 3 8B, the method reduces the Attack Success Rate (ASR) from approximately 90% in the original model to under 5% against embedding-space attacks, significantly outperforming existing "circuit breaking" techniques while preserving general model capabilities.
Introduction
Despite extensive safety alignment, LLMs are susceptible to adversarial prompts designed to elicit harmful content. These range from text-based input-space attacks to more potent embedding-space attacks that directly manipulate internal vector representations. Current defenses, such as "circuit breaking," attempt to disrupt internal logic but often lack the mathematical rigor to effectively separate harmful and benign representations in high-dimensional space, leaving them vulnerable to adversarial noise.
Methodology
The proposed defense treats safety as a representation engineering problem. It utilizes a Triplet-Based Loss to focus on relative distances between representations. The model is trained to move harmful query representations toward a cluster of safe, nonsensical "broken" states (the positive target) and away from their original harmful states (the negative target). Simultaneously, benign representations are constrained to remain near their original functional states to preserve utility.
To enhance robustness, the authors employ Adversarial Hard Negative Mining. This involves generating "hard" harmful representations that are mathematically similar to benign ones. Training against these edge cases forces the model to establish sharper boundaries within its internal representation space, making it more resilient to high-dimensional noise.
Experimental Results
The "Triplet + Adv" defense demonstrates superior robustness across multiple benchmarks. On Llama 3 8B, embedding-space attack success rates dropped from 90.24% in the original model to 4.88%. This represents a significant improvement over the previous state-of-the-art, Circuit Breaking, which maintained an ASR of approximately 29%.
Crucially, this method avoids the performance degradation seen in prior approaches. While methods like RepBend can cause math performance to drop by over 25%, the Triplet defense maintains performance within 1% of the original model across benchmarks like MMLU and GSM8K. The defense works by "breaking" the model's ability to formulate coherent harmful thoughts, resulting in incoherent gibberish (e.g., //„„ / /, / / / /, /) rather than bypassable refusals.
Conclusion and Future Work
While highly effective on Llama 3, the defense shows some sensitivity to model architecture, with Mistral 7B remaining more vulnerable. Additionally, the computational cost of adversarial training remains a challenge for scaling to larger models. Future research will focus on refining "positive" targets to minimize the risk of over-refusal on complex benign prompts and exploring more efficient training regimes.
Summary updated