[Paper Review] Jailbreak and Guard Aligned Language Models with Only Few In-Context Demonstrations
The paper shows that few in-context demonstrations can jailbreak or guard aligned LLMs without fine-tuning, introducing In-Context Attack (ICA) and In-Context Defense (ICD) and evaluating their effectiveness.
Large Language Models (LLMs) have shown remarkable success in various tasks, yet their safety and the risk of generating harmful content remain pressing concerns. In this paper, we delve into the potential of In-Context Learning (ICL) to modulate the alignment of LLMs. Specifically, we propose the In-Context Attack (ICA) which employs harmful demonstrations to subvert LLMs, and the In-Context Defense (ICD) which bolsters model resilience through examples that demonstrate refusal to produce harmful responses. We offer theoretical insights to elucidate how a limited set of in-context demonstrations can pivotally influence the safety alignment of LLMs. Through extensive experiments, we demonstrate the efficacy of ICA and ICD in respectively elevating and mitigating the success rates of jailbreaking prompts. Our findings illuminate the profound influence of ICL on LLM behavior, opening new avenues for improving the safety of LLMs.
Motivation & Objective
- Investigate how in-context learning can alter the alignment of LLMs without parameter updates.
- Demonstrate an In-Context Attack (ICA) that jailbreaks aligned LLMs using few demonstrations.
- Demonstrate an In-Context Defense (ICD) that strengthens robustness against adversarial prompts.
- Compare ICA/ICD against optimization-based attacks and existing defenses.
- Provide insights into the safety implications of in-context manipulation of LLM alignment.
Proposed method
- Define In-Context Attack (ICA) by concatenating k adversarial demonstrations with a target prompt to produce harmful outputs.
- Demonstrate In-Context Defense (ICD) by prepending demonstrations of safe responses to harmful prompts to reduce jailbreak success.
- Evaluate ICA/ICD on Vicuna-7b and Llama2-7b-chat under black-box and white-box settings with GCG attacks as threat models.
- Compare ICA/ICD against optimization-based attacks (GBDA, PEZ, GCG) under perplexity defenses.
- Measure Attack Success Rate (ASR) and analyze detection via perplexity filters and robustness under transfer/adaptive attacks.
Experimental results
Research questions
- RQ1Can few in-context demonstrations effectively jailbreak an aligned LLM without fine-tuning?
- RQ2Can in-context demonstrations be used to defend against jailbreak attempts in a black-box setting?
- RQ3How do ICA and ICD compare to optimization-based attacks and other defenses in terms of effectiveness and efficiency?
- RQ4What is the impact of demonstration count on attack success and defense robustness?
- RQ5Do defenses generalize to transfer and white-box adversarial scenarios?
Key findings
- ICA can increase jailbreak success from 0% to 44% with five demonstrations.
- ICA is more efficient than optimization-based attacks, requiring a single forward pass and seconds of computation.
- ICD can dramatically reduce adversarial attack success, lowering transfer and white-box ASR to near 0% with a few demonstrations.
- Perplexity-based detection can fail against ICA because demonstrations are natural language and have low perplexity.
- ICD shows robust performance across Vicuna-7b and Llama2-7b-chat in both transfer and white-box settings, with notable ASR reductions.
- ICD increases robustness while maintaining low computational overhead compared to other defenses.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.