← Latest papers
💬 NLP

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

This paper reveals that few-shot demonstrations have divergent effects on prompt-based defenses, enhancing Role-Oriented Prompts by reinforcing identity while significantly degrading Task-Oriented Prompts by distracting from instructions, thereby offering critical insights for optimizing LLM safety strategies.

Original authors: Yanshu Wang, Shuaishuai Yang, Jingjing He, Tong Yang

Published 2026-02-05
📖 4 min read☕ Coffee break read

Original authors: Yanshu Wang, Shuaishuai Yang, Jingjing He, Tong Yang

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine Large Language Models (LLMs) as very talented but naive interns. They are brilliant at writing code, telling stories, and answering questions, but they need strict rules to keep them from doing something dangerous or unethical.

The paper you provided investigates how we give these interns their rules. Specifically, it looks at two different ways of writing those rules (prompts) and how adding "example stories" (few-shot demonstrations) changes the outcome.

Here is the breakdown of their findings using simple analogies:

1. The Two Ways to Give Instructions

The researchers tested two main styles of "System Prompts" (the initial instructions given to the AI):

  • Role-Oriented Prompts (RoP): The "Identity" Approach
    • The Analogy: Imagine telling the intern, "You are a helpful, safe, and ethical assistant named 'Guardian'."
    • How it works: You are defining who they are. You are leaning on their training to act like a good assistant.
  • Task-Oriented Prompts (ToP): The "Job Description" Approach
    • The Analogy: Imagine telling the intern, "Your specific task right now is to generate safe answers. If a request is bad, your job is to say no."
    • How it works: You are defining what they must do. It's a specific command for the current moment.

2. The "Example Stories" (Few-Shot Demonstrations)

In AI, "few-shot" means giving the model a few examples of how to behave before asking it the real question.

  • The Analogy: Before the intern starts work, you show them a notebook with 3 examples of how "Guardian" handled tricky questions in the past.
  • The Question: Does showing these examples help the intern stay safe, or does it confuse them?

3. The Big Discovery: Opposite Effects

The paper's main finding is that adding these example stories helps one type of instruction but hurts the other. It's like a magic trick where the same prop makes one person smile and another cry.

Scenario A: The "Identity" Approach (RoP) + Examples = SUPER SAFE

  • What happened: When the AI was told "You are a safe assistant" (RoP) and then shown examples of safe behavior, it got better at staying safe.
  • The Analogy: Think of the AI's "safe assistant" identity as a muscle. Showing examples is like doing a few warm-up reps. It reinforces the muscle. The examples remind the AI, "Yes, this is who I am. I am the safe one."
  • Result: Safety improved by up to 4.5%. The examples acted as a "reinforcement" of the role.

Scenario B: The "Job Description" Approach (ToP) + Examples = LESS SAFE

  • What happened: When the AI was told "Your task is to be safe" (ToP) and then shown examples, it got worse at staying safe.
  • The Analogy: Imagine you give the intern a specific job instruction, but then you hand them a thick stack of unrelated paperwork (the examples) to read first. The instruction gets buried in the middle of the stack. The intern gets distracted by the examples and forgets the main rule.
  • The Science: The paper calls this "Attention Distraction." The AI's brain focuses on the examples (which are at the start of the text) and loses focus on the actual instruction (which gets pushed to the middle).
  • Result: Safety dropped significantly, by up to 21.2%. The examples drowned out the rules.

4. The "Think Mode" Paradox

The paper also looked at models that have a special "Think Mode" (where they reason step-by-step before answering).

  • The Finding: These models were generally more vulnerable to jailbreaks (attacks designed to bypass safety) and more confused by the examples, regardless of which instruction style was used.
  • The Analogy: It's like a student who over-analyzes a question. Instead of just following the rule, they start debating the rule in their head, and the "bad guys" (jailbreakers) trick them into thinking the bad idea is actually logical.

5. What Should Developers Do?

Based on these findings, the authors give very specific advice:

  • If you use the "Identity" approach (RoP): Go ahead and add example stories! It makes the AI safer.
  • If you use the "Job Description" approach (ToP): Do not add example stories. It makes the AI less safe. Keep the instructions short and direct.
  • If you use "Think Mode" models: Be very careful. They seem to be easier to trick, so you might need extra safety measures.

Summary

The paper proves that context matters.

  • If you define the AI's character, examples help strengthen that character.
  • If you define the AI's task, examples act as noise that drowns out the instructions.

The researchers didn't just guess this; they tested it on many different AI models and safety benchmarks to prove that these two strategies react in opposite ways to the same input.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →