Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

On Prompt-Driven Safeguarding for Large Language Models

About

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.

Chujie Zheng, Fan Yin, Hao Zhou, Fandong Meng, Jie Zhou, Kai-Wei Chang, Minlie Huang, Nanyun Peng• 2024

Related benchmarks

TaskDatasetResultRank
Safety EvaluationToxigen
Safety94
77
Language UnderstandingMMLU
MMLU Score64
70
Refusal Rate EvaluationOK (test)--
56
Jailbreak DefenseStrongREJECT--
54
Jailbreak DefenseJailbreakBench
Rate of Response Safety70
20
Safety EvaluationDAN
Safety Score (DAN)83
18
General ReasoningBBH
Score67
12
False Refusal EvaluationORB
Score74
6
False Refusal EvaluationXSTest
Score70
6
Safety EvaluationTülu Safety Benchmarks 3
DAN Score80
6
Showing 10 of 15 rows

Other info

Follow for update