Skip to main content
QUICK REVIEW

[Paper Review] Backdoor Attacks for In-Context Learning with Language Models

Nikhil Kandpal, Matthew Jagielski|arXiv (Cornell University)|Jul 27, 2023
Adversarial Robustness in Machine LearningComputer Science10 citations
TL;DR

The paper demonstrates backdoor attacks on large language models' in-context learning by fine-tuning with poisoned prompts, showing high attack success rates across tasks and model sizes, and analyzes white-box and black-box defenses.

ABSTRACT

Because state-of-the-art language models are expensive to train, most practitioners must make use of one of the few publicly available language models or language model APIs. This consolidation of trust increases the potency of backdoor attacks, where an adversary tampers with a machine learning model in order to make it perform some malicious behavior on inputs that contain a predefined backdoor trigger. We show that the in-context learning ability of large language models significantly complicates the question of developing backdoor attacks, as a successful backdoor must work against various prompting strategies and should not affect the model's general purpose capabilities. We design a new attack for eliciting targeted misclassification when language models are prompted to perform a particular target task and demonstrate the feasibility of this attack by backdooring multiple large language models ranging in size from 1.3 billion to 6 billion parameters. Finally we study defenses to mitigate the potential harms of our attack: for example, while in the white-box setting we show that fine-tuning models for as few as 500 steps suffices to remove the backdoor behavior, in the black-box setting we are unable to develop a successful defense that relies on prompt engineering alone.

Motivation & Objective

  • Evaluate the feasibility of backdoor attacks on LMs with in-context learning across multiple prompt styles.
  • Assess how backdoors affect target task performance and auxiliary tasks.
  • Investigate model size effects on backdoor robustness and potential defenses in white-box and black-box settings.
  • Provide guidance on defense mechanisms and limitations in practical deployments.

Proposed method

  • Formalize a threat model for backdoors in in-context learning where the attacker selects a target task, a backdoor behavior, and a trigger.
  • Fine-tune pre-trained LM variants (GPT-Neo 1.3B/2.7B, GPT-J 6B, GPT-2 XL 1.5B) on a poisoned dataset that mixes clean and triggered examples for the target task.
  • Use a loss combining cross-entropy on poisoned data with an L2 distance to the original parameters to preserve general capabilities.
  • Evaluate ASR on held-out prompts and measure target task accuracy and auxiliary task performance across multiple prompts.
  • Test robustness of backdoors to prompt variation across models; analyze how prompt accuracy correlates with ASR.

Experimental results

Research questions

  • RQ1Can backdoors be induced in LMs to trigger target-task misbehavior regardless of prompting strategy?
  • RQ2How does model size affect backdoor robustness to prompt variation and what is the impact on auxiliary tasks?
  • RQ3Can standard defenses (white-box fine-tuning, black-box prompt engineering) mitigate such backdoors?
  • RQ4What is the relationship between prompt-driven accuracy and backdoor effectiveness across tasks?

Key findings

  • Backdoored models achieve high attack success rates on triggered inputs across several target tasks and models, with ASR often near 1 for larger models.
  • Backdoors retain comparable or higher clean-task accuracy relative to the pre-trained model on the target task.
  • Auxiliary task performance degrades in some cases but remains largely preserved (often ≥75% of original for several tasks).
  • Larger models show greater robustness to prompt variation, with 6B models achieving ASR > 90% across unseen prompts for sentiment tasks.
  • Prompt engineering that maximizes in-context accuracy tends to increase backdoor effectiveness, showing a strong correlation between clean task accuracy and backdoor ASR.
  • White-box defense via fine-tuning for ~500 steps effectively removes the backdoor, with removal cost largely independent of attacker effort; black-box defenses via prompt engineering are less reliable, though prompts that decouple the trigger from the backdoor can reduce ASR.
  • In black-box settings, inserting the backdoor trigger into context examples can decrease ASR, especially in smaller models, suggesting some mitigative potential from prompt design.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.