Feature-Aware Malicious Output Detection and Mitigation

Weilong Dong, Peiguang Li, Yu Tian, Xinyi Zeng, Fengdi Li +1 more
4/12/2025
cs.CL

No confident code implementation found for this paper.

Abstract

The rapid advancement of large language models (LLMs) has brought significant benefits to various domains while introducing substantial risks. Despite being fine-tuned through reinforcement learning, LLMs lack the capability to discern malicious content, limiting their defense against jailbreak. To address these safety concerns, we propose a feature-aware method for harmful response rejection (FMM), which detects the presence of malicious features within the model's feature space and adaptively adjusts the model's rejection mechanism. By employing a simple discriminator, we detect potential malicious traits during the decoding phase. Upon detecting features indicative of toxic tokens, FMM regenerates the current token. By employing activation patching, an additional rejection vector is incorporated during the subsequent token generation, steering the model towards a refusal response. Experimental results demonstrate the effectiveness of our approach across multiple language models and diverse attack techniques, while crucially maintaining the models' standard generation capabilities.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{dong2025featureaware,
  title  = {Feature-Aware Malicious Output Detection and Mitigation},
  author = {Weilong Dong and Peiguang Li and Yu Tian and Xinyi Zeng and Fengdi Li and Sirui Wang},
  year   = {2025},
  eprint = {2504.09191},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2504.09191v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2504.09191.svg)](https://codeofpaper.com/paper/2504.09191)

Discussion