AI
New Method Uses Embedding Separation to Make AI Models Resist Adversarial Attacks
Researchers propose a fine-tuning technique that pushes harmful and harmless content further apart in AI models' internal representations to improve safety against jailbreaking attempts.
A team of computer scientists has developed a new safety mechanism for large language models designed to make them more resilient to adversarial attacks that attempt to bypass their safeguards.
How Current Safety Protections Fall Short#
Standard safety alignment practices don't fully eliminate the risk that LLMs will generate harmful outputs when subjected to carefully crafted attacks. Security researchers have observed that adversarial attack methods typically succeed by shifting harmful content embeddings—the numerical representations the model uses internally—into regions associated with harmless responses. This vulnerability suggests a possible defense: if harmful and harmless embeddings were pushed farther apart, adversaries would need to make larger shifts to mount successful attacks, potentially damaging the semantic coherence of their prompts in the process.
Introducing Embedding Space Separation#
The researchers introduced Embedding Space Separation (ES2), a fine-tuning approach that expands the distance between harmful and harmless embeddings in a model's internal representation space. Simply maximizing this separation, however, risks degrading the model's general capabilities and quality.
To address this trade-off, the team deployed two regularization techniques:
- Embedding anchor loss: keeps harmless embeddings oriented similarly to those in a frozen reference model
- KL-divergence loss: ensures output distributions on benign prompts remain aligned with the base model
Results and Trade-offs#
Testing showed that ES2 effectively defended against multiple types of adversarial attacks. Models refined with this method retained performance comparable to baseline versions on general tasks, though some degradation appeared on specific benchmarks. The findings suggest that ES2 offers a practical way to strengthen LLM safety without catastrophic capability loss.

