LLMs Encode Harmfulness and Refusal Separately

Jiachen Zhao, Jing Huang, Zhengxuan Wu, David Bau, Weiyan Shi

Abstract

Recent research reveals that Large Language Models (LLMs) maintain separate internal representations for the "harmfulness" of a prompt and the decision to "refuse" it. By analyzing latent spaces at specific token positions, researchers identified distinct directions for these concepts. This discovery led to the development of Latent Guard, an intrinsic safety mechanism that outperforms external classifiers in detecting sophisticated jailbreaks and remains robust even after adversarial finetuning. This paper shifts the focus from behavioral alignment to representational alignment in AI safety.

Introduction

The current paradigm for LLM safety relies on "refusal training"—teaching models to output specific phrases like "I can't help with that" when encountering harmful prompts. However, this approach suffers from two critical vulnerabilities: over-refusal, where models reject benign prompts due to surface-level triggers, and jailbreaking, where adversarial prompts bypass refusal mechanisms despite the request being harmful.

This study investigates whether LLMs truly understand harmfulness or merely learn a shallow mapping to refusal. By proving these concepts are decoupled, the researchers provide a more robust foundation for securing AI systems.

Methodology

The researchers examined the hidden states of Llama 2, Llama 3, and Qwen2 at two critical token positions:

  • $t_{inst}$: The final token of the user's instruction.
  • $t_{post-inst}$: The final token of the prompt template (e.g., the [/INST] tag).

To validate these findings, they employed activation steering and a Reply Inversion Task. In this task, they asked the model to judge the harmfulness of a prompt. Steering along the "harmfulness direction" changed the model's internal judgment (e.g., from "No" to "Certainly"), while steering along the "refusal direction" triggered a refusal response without altering the underlying judgment of harm.

Conceptual overview of the separation between internal belief (harmfulness) and behavior (refusal).

Key Insights: Spatial and Temporal Separation

The study found that harmfulness and refusal are separated both spatially in the latent space and temporally during processing. Harmfulness is primarily encoded early at the $t_{inst}$ position, while refusal signals emerge later at $t_{post-inst}$.

This separation explains how different jailbreaks function:

  1. Persuasion Jailbreaks: These trick the model into believing a harmful prompt is actually harmless, altering the belief at $t_{inst}$.
  2. Adversarial Suffixes (e.g., GCG): These merely suppress the refusal signal at $t_{post-inst}$ while the model's internal belief at $t_{inst}$ remains correctly flagged as "harmful."
Layer-wise analysis across Llama 3, Llama 2, and Qwen2 showing the emergence of harmfulness signals at t_inst and refusal signals at t_post-inst.

Furthermore, the researchers discovered that "lobotomy" attacks—adversarial finetuning designed to make models unsafe—break the refusal mechanism but leave the internal perception of harmfulness largely intact. This suggests that the understanding of harm is a core part of the model's world knowledge, whereas refusal is a fragile, surface-level behavior.

Latent Guard and Results

Leveraging these insights, the authors developed Latent Guard, which uses the model's own internal harmfulness beliefs as a safeguard.

  • Detection Accuracy: Latent Guard achieved performance comparable to or better than Llama Guard 3 8B.
  • Jailbreak Robustness: On Qwen2, Latent Guard detected 75% of persuasion jailbreaks, significantly outperforming Llama Guard 3, which caught only 17.8%.
  • Causal Evidence: Steering harmless instructions along the harmfulness direction elicited refusal rates as high as 94% on Llama 3, proving the extracted latent vectors are functionally meaningful.

Conclusion

This work demonstrates that LLMs possess a robust internal understanding of harm that is distinct from their refusal behavior. By moving toward representational alignment—ensuring the model's internal beliefs match safety goals—developers can create safeguards like Latent Guard that are more resilient to adversarial attacks than traditional behavioral training.

Summary updated

BibTeX
@inproceedings{zhao2025llms,
  author = {Jiachen Zhao and Jing Huang and Zhengxuan Wu and David Bau and Weiyan Shi},
  title = {{LLMs Encode Harmfulness and Refusal Separately}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=zLkpt30ngy},
}
Figure