Skip to main content
QUICK REVIEW

[Paper Review] Adversarial Demonstration Attacks on Large Language Models

Jiongxiao Wang, Zichen Liu|arXiv (Cornell University)|May 24, 2023
Adversarial Robustness in Machine LearningComputer Science16 citations
TL;DR

The paper introduces advICL, an adversarial attack that manipulates only in-context demonstrations to corrupt LLM in-context learning, and its transferable variant T-advICL that generalizes to unseen inputs.

ABSTRACT

With the emergence of more powerful large language models (LLMs), such as ChatGPT and GPT-4, in-context learning (ICL) has gained significant prominence in leveraging these models for specific tasks by utilizing data-label pairs as precondition prompts. While incorporating demonstrations can greatly enhance the performance of LLMs across various tasks, it may introduce a new security concern: attackers can manipulate only the demonstrations without changing the input to perform an attack. In this paper, we investigate the security concern of ICL from an adversarial perspective, focusing on the impact of demonstrations. We propose a novel attack method named advICL, which aims to manipulate only the demonstration without changing the input to mislead the models. Our results demonstrate that as the number of demonstrations increases, the robustness of in-context learning would decrease. Additionally, we also identify the intrinsic property of the demonstrations is that they can be used (prepended) with different inputs. As a result, it introduces a more practical threat model in which an attacker can attack the test input example even without knowing and manipulating it. To achieve it, we propose the transferable version of advICL, named Transferable-advICL. Our experiment shows that the adversarial demonstration generated by Transferable-advICL can successfully attack the unseen test input examples. We hope that our study reveals the critical security risks associated with ICL and underscores the need for extensive research on the robustness of ICL, particularly given its increasing significance in the advancement of LLMs.

Motivation & Objective

  • Assess the security risks of demonstrations in in-context learning (ICL) for large language models (LLMs).
  • Develop an attack that only perturbs demonstrations without altering the input, and evaluate its impact on ICL robustness.
  • Explore the transferability of adversarial demonstrations to unseen inputs and across models and templates.

Proposed method

  • Define in-context learning formally as a conditional text generation problem with demonstrations C and test input x_test.
  • Extend the TextAttack framework with demonstration masking to perturb only demonstrations.
  • Introduce per-demonstration perturbation bounds Delta_i using cosine similarity constraints to generate high-quality adversarial demonstrations.
  • Formulate an optimization objective to minimize the loss L under perturbations on demonstrations: min_delta L(f({C_delta}, s(x_test,_)), y_test).
  • Employ a greedy, black-box perturbation strategy (character/word-level) constrained by similarity to generate adversarial demonstrations.

Experimental results

Research questions

  • RQ1Can demonstrations in ICL be perturbed to mislead LLMs without changing the test input?
  • RQ2How does the number of demonstrations affect robustness of ICL under demonstration-only attacks?
  • RQ3Can adversarial demonstrations transfer to unseen inputs and across models?
  • RQ4Does a transferable, universal-style attack on demonstrations exist and how effective is it across templates and datasets?

Key findings

  • AdvICL achieves high attack success rates by only perturbing demonstrations (e.g., up to 97.72% ASR on LLaMA-7B with DBpedia 8-shot).
  • Increasing the number of demonstrations generally increases ASR, revealing a robustness risk in multi-shot ICL.
  • Demonstrations can be prepended to different inputs, enabling a transferable threat model where attackers need not know the test input.
  • The Transferable- advICL (T- advICL) produces universally adversarial demonstrations that significantly improve transferability across unseen inputs (e.g., 72.32% ASR on DBpedia for unseen inputs).
  • Perceptual evaluation shows high quality of adversarial demonstrations (AEQS around 90% with strong CosSim and BLEU scores, and Adv PPL reductions).
  • T- advICL converges with around R=3 iterations and benefits from larger candidate sets k, improving stability and transferability.

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.