How Few-shot Demonstrations Affect Prompt-based Defenses Against LLM Jailbreak Attacks

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Wang, Yanshu, Yang, Shuaishuai, He, Jingjing, Yang, Tong
Format: Preprint
Publié: 2026
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866910011179925504
author Wang, Yanshu
Yang, Shuaishuai
He, Jingjing
Yang, Tong
author_facet Wang, Yanshu
Yang, Shuaishuai
He, Jingjing
Yang, Tong
contents Large Language Models (LLMs) face increasing threats from jailbreak attacks that bypass safety alignment. While prompt-based defenses such as Role-Oriented Prompts (RoP) and Task-Oriented Prompts (ToP) have shown effectiveness, the role of few-shot demonstrations in these defense strategies remains unclear. Prior work suggests that few-shot examples may compromise safety, but lacks investigation into how few-shot interacts with different system prompt strategies. In this paper, we conduct a comprehensive evaluation on multiple mainstream LLMs across four safety benchmarks (AdvBench, HarmBench, SG-Bench, XSTest) using six jailbreak attack methods. Our key finding reveals that few-shot demonstrations produce opposite effects on RoP and ToP: few-shot enhances RoP's safety rate by up to 4.5% through reinforcing role identity, while it degrades ToP's effectiveness by up to 21.2% through distracting attention from task instructions. Based on these findings, we provide practical recommendations for deploying prompt-based defenses in real-world LLM applications.
format Preprint
id arxiv_https___arxiv_org_abs_2602_04294
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle How Few-shot Demonstrations Affect Prompt-based Defenses Against LLM Jailbreak Attacks
Wang, Yanshu
Yang, Shuaishuai
He, Jingjing
Yang, Tong
Computation and Language
Artificial Intelligence
Cryptography and Security
68T50
I.2.7; K.4.1
Large Language Models (LLMs) face increasing threats from jailbreak attacks that bypass safety alignment. While prompt-based defenses such as Role-Oriented Prompts (RoP) and Task-Oriented Prompts (ToP) have shown effectiveness, the role of few-shot demonstrations in these defense strategies remains unclear. Prior work suggests that few-shot examples may compromise safety, but lacks investigation into how few-shot interacts with different system prompt strategies. In this paper, we conduct a comprehensive evaluation on multiple mainstream LLMs across four safety benchmarks (AdvBench, HarmBench, SG-Bench, XSTest) using six jailbreak attack methods. Our key finding reveals that few-shot demonstrations produce opposite effects on RoP and ToP: few-shot enhances RoP's safety rate by up to 4.5% through reinforcing role identity, while it degrades ToP's effectiveness by up to 21.2% through distracting attention from task instructions. Based on these findings, we provide practical recommendations for deploying prompt-based defenses in real-world LLM applications.
title How Few-shot Demonstrations Affect Prompt-based Defenses Against LLM Jailbreak Attacks
topic Computation and Language
Artificial Intelligence
Cryptography and Security
68T50
I.2.7; K.4.1
url https://arxiv.org/abs/2602.04294