cs.CLMar 1, 2026

Enhancing Safety of Large Language Models via Embedding Space Separation

Authors: Xu Zhao, Xiting Wang, Weiran Shen

Organizations: Gaoling School of Artificial Intelligence, Renmin University of China.

Abstract

Large language models (LLMs) have achieved impressive capabilities, yet ensuring their safety against harmful prompts remains a critical challenge. Recent work has revealed that the latent representations (embeddings) of harmful and safe queries in LLMs typically exhibit linear separability, a property that has been exploited to construct attacks by perturbing the embeddings of harmful queries towards the safe subspace. Motivated by this observation, we propose a representation-level fine-tuning approach, named Embedding Space Separation (ES2), which improves LLM safety by explicitly enlarging the distance between harmful and safe representations in the embedding space. To prevent degradation of model's general capabilities, we introduce a Kullback-Leibler (KL) divergence regularization term into the loss function, which constrains the logits of the fine-tuned model to align with those of the original base model on harmless inputs. We evaluate our method on several open-source LLMs using standard safety benchmarks. Extensive experimental results demonstrate that our approach substantially improves model safety while maintaining comparable general capabilities.

Figures & tables

Appendix figures & tables6 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Safety Anchor: Defending Harmful Fine-tuning via Geometric Bottlenecks

    May 7, 2026Guoxin Lu, Letian Sha, Qing Wang +4LLM Fine-TuningLLM Safety Alignment

  2. Finding and Reactivating Post-Trained LLMs' Hidden Safety Mechanisms

    Mar 10, 2026Mingjie Li, Wai Man Si, Michael Backes +2LLM SafetyLLM Safety Alignment

  3. HyperSafe: Inference-Time Safety Recovery for Fine-Tuned Language Models

    Jul 13, 2026Aznaur Aliev, Carlos Hinojosa, Abdelrahman Eldesokey +3LLM Fine-TuningLLM Safety Alignment