On Prompt-Driven Safeguarding for Large Language Models

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Zheng, Chujie, Yin, Fan, Zhou, Hao, Meng, Fandong, Zhou, Jie, Chang, Kai-Wei, Huang, Minlie, Peng, Nanyun
Format: Preprint
Veröffentlicht: 2024
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866911899622309888
author Zheng, Chujie
Yin, Fan
Zhou, Hao
Meng, Fandong
Zhou, Jie
Chang, Kai-Wei
Huang, Minlie
Peng, Nanyun
author_facet Zheng, Chujie
Yin, Fan
Zhou, Hao
Meng, Fandong
Zhou, Jie
Chang, Kai-Wei
Huang, Minlie
Peng, Nanyun
contents Prepending model inputs with safety prompts is a common practice for safeguarding large language models (LLMs) against queries with harmful intents. However, the underlying working mechanisms of safety prompts have not been unraveled yet, restricting the possibility of automatically optimizing them to improve LLM safety. In this work, we investigate how LLMs' behavior (i.e., complying with or refusing user queries) is affected by safety prompts from the perspective of model representation. We find that in the representation space, the input queries are typically moved by safety prompts in a "higher-refusal" direction, in which models become more prone to refusing to provide assistance, even when the queries are harmless. On the other hand, LLMs are naturally capable of distinguishing harmful and harmless queries without safety prompts. Inspired by these findings, we propose a method for safety prompt optimization, namely DRO (Directed Representation Optimization). Treating a safety prompt as continuous, trainable embeddings, DRO learns to move the queries' representations along or opposite the refusal direction, depending on their harmfulness. Experiments with eight LLMs on out-of-domain and jailbreak benchmarks demonstrate that DRO remarkably improves the safeguarding performance of human-crafted safety prompts, without compromising the models' general performance.
format Preprint
id arxiv_https___arxiv_org_abs_2401_18018
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle On Prompt-Driven Safeguarding for Large Language Models
Zheng, Chujie
Yin, Fan
Zhou, Hao
Meng, Fandong
Zhou, Jie
Chang, Kai-Wei
Huang, Minlie
Peng, Nanyun
Machine Learning
Artificial Intelligence
Computation and Language
Prepending model inputs with safety prompts is a common practice for safeguarding large language models (LLMs) against queries with harmful intents. However, the underlying working mechanisms of safety prompts have not been unraveled yet, restricting the possibility of automatically optimizing them to improve LLM safety. In this work, we investigate how LLMs' behavior (i.e., complying with or refusing user queries) is affected by safety prompts from the perspective of model representation. We find that in the representation space, the input queries are typically moved by safety prompts in a "higher-refusal" direction, in which models become more prone to refusing to provide assistance, even when the queries are harmless. On the other hand, LLMs are naturally capable of distinguishing harmful and harmless queries without safety prompts. Inspired by these findings, we propose a method for safety prompt optimization, namely DRO (Directed Representation Optimization). Treating a safety prompt as continuous, trainable embeddings, DRO learns to move the queries' representations along or opposite the refusal direction, depending on their harmfulness. Experiments with eight LLMs on out-of-domain and jailbreak benchmarks demonstrate that DRO remarkably improves the safeguarding performance of human-crafted safety prompts, without compromising the models' general performance.
title On Prompt-Driven Safeguarding for Large Language Models
topic Machine Learning
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2401.18018