Jailbreak and Guard Aligned Language Models With Only Few In-Context Demonstrations

By Zeming Wei, Yifei Wang, Yisen Wang. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2023

497 citations recorded by the source corpus.

Large Language Models (LLMs) have demonstrated remarkable success across diverse applications, yet their susceptibility to malicious exploitation remains a critical challenge. Notably, LLMs are known to be vulnerable to jailbreaking attacks, where adversaries craft malicious inputs to induce harmful or unethical outputs. In this paper, motivated by the unique effectiveness and scalability of In-Context Learning (ICL) in LLMs, we explore its potential to modulate the safety alignment of LLMs. Specifically, we propose the In-Context Attack (ICA), which employs harmful demonstrations to subvert LLMs’ safety, and the In-Context Defense (ICD), which bolsters their resilience through examples that demonstrate refusal to produce harmful responses. By adjusting the distribution of safety in LLM outputs through adversarial demonstrations, our proposed in-context attack and defense facilitate effective manipulation of their alignment. We first provide theoretical insights to illustrate how minimal in-context demonstrations can efficiently alter safety alignment. Empirically, we validate ICA and ICD across multiple models, datasets, and attack baselines, showing their efficacy and scalability for red-teaming evaluations and robust safeguards for real-world deployment. Overall, our work unveils the pivotal yet understudied role of ICL in LLM safety, opening new avenues for understanding and improving them.

Subfields: Artificial Intelligence, Safety Research, Signal Processing

View Paper: https://www.semanticscholar.org/paper/6b135e922a0c673aeb0b05c5aeecdb6c794791c6

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Artificial Intelligence

  1. Tongliang Liu
  2. David Kristjanson Duvenaud
  3. Rylan Schaeffer
  4. Carson E. Denison
  5. Jared Kaplan
  6. Jianing Zhu
  7. Karina Nguyen
  8. Meg Tong

In Safety Research

  1. David Kristjanson Duvenaud
  2. Meg Tong
  3. Esin Durmus

In Signal Processing

  1. Tongliang Liu
  2. David Kristjanson Duvenaud

Citations in the corpus