Enhancing Safety of Large Language Models via Embedding Space Separation

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Zhao, Xu, Wang, Xiting, Shen, Weiran
Formato: Preprint
Publicado: 2026
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866915877962645504
author Zhao, Xu
Wang, Xiting
Shen, Weiran
author_facet Zhao, Xu
Wang, Xiting
Shen, Weiran
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2603_20206
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Enhancing Safety of Large Language Models via Embedding Space Separation
Zhao, Xu
Wang, Xiting
Shen, Weiran
Computation and Language
Artificial Intelligence
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.
title Enhancing Safety of Large Language Models via Embedding Space Separation
topic Computation and Language
Artificial Intelligence
url https://arxiv.org/abs/2603.20206