Adversarial Robustness of Prompt-based Few-Shot Learning for Natural Language Understanding

Venkata Prabhakara Sarath Nookala, Gaurav Verma, Subhabrata Mukherjee, Srijan Kumar

This paper explores the security side of one of the most popular trends in NLP: prompt-based few-shot learning. While these models achieve impressive performance with very little data, this research reveals a critical vulnerability—they are often significantly less robust to adversarial attacks than their fully supervised counterparts.

TL;DR

This study evaluates the adversarial robustness of prompt-based few-shot learning (FSL) methods across several NLU tasks. It finds that while "vanilla" prompt-based models are more fragile than fully fine-tuned ones, leveraging unlabeled data or ensembling multiple prompts can flip this trend, making few-shot models surprisingly resilient to malicious perturbations.

What Problem Does This Paper Address?

Prompt-based few-shot learning has revolutionized how we deploy large language models (LLMs), allowing them to tackle new tasks with as few as 16 examples. Recent studies suggested these models are robust to "natural" distribution shifts (like a change in writing style).

However, there is a major gap in our understanding of their adversarial robustness—their ability to withstand inputs specifically engineered by an attacker to cause a mistake (e.g., changing a single word to a synonym that flips the model's prediction). As these models are integrated into sensitive applications like hate speech detection, understanding their susceptibility to malicious manipulation is a critical safety concern.

Methods

The authors conducted an extensive empirical study comparing several state-of-the-art FSL methods against traditional full fine-tuning (Full FT). The methods evaluated include:

  • Classic-FT: Standard fine-tuning on a small number of labeled examples.
  • LM-BFF: A popular prompt-based method that uses "demonstrations" (similar examples) within the prompt.
  • PET (Pattern-Exploiting Training): Uses multiple different prompt templates and ensembles their predictions.
  • iPET: An iterative version of PET that leverages unlabeled data to self-train the model.

The researchers systematically varied the number of examples ($K$), model sizes (from 12M to 235M parameters), and encoder types (BERT, RoBERTa, ALBERT) to isolate which factors contribute most to robustness.

Datasets

The models were trained on six tasks from the GLUE benchmark (SST-2, QQP, MNLI-m, MNLI-mm, RTE, and QNLI). To evaluate robustness, the authors used AdvGLUE, a benchmark containing human-validated adversarial examples. Unlike automated attacks that can produce nonsensical text, AdvGLUE ensures the perturbations are high-quality and preserve the original meaning for a human reader.

Key Insights and Ideas

  • Prompting isn't a robustness panacea: Contrary to findings on natural distribution shifts, vanilla prompt-based models (LM-BFF) actually show a larger relative performance drop under adversarial attack than fully supervised models.
  • Unlabeled data is a powerful shield: The most striking finding is that using unlabeled data (via iPET) significantly improves robustness. By exposing the model to a more diverse set of data during self-training, it learns features that are harder for adversaries to exploit.
  • Diversity through Ensembling: Using multiple prompts (PET) helps mitigate the sensitivity of a single prompt to specific word changes, leading to better adversarial stability.
  • Scale helps, but doesn't solve everything: Increasing model size and the number of few-shot examples both improve robustness, but the gap between in-domain and adversarial performance remains significant.
  • Pre-training objectives matter: RoBERTa encoders were found to be more robust than BERT or ALBERT of similar sizes, likely because RoBERTa’s "whole-word masking" pre-training creates more reliable textual representations.

Key Results

The study uses "Relative Drop" (the percentage decrease in accuracy from the original set to the adversarial set) as the primary metric for robustness.

Figure 1: Overview of our study. We compare the relative gap between the in-domain and adversarial per- formance of different state-of-the-art prompt-based few- shot learning methods with that of the models trained with fully supervised learning.
  • Vanilla Vulnerability: LM-BFF had an average relative drop of 36.9%, performing worse than Full FT (35.3%).
  • The Robustness Flip: iPET and PET achieved relative drops of 28.1% and 27.2% respectively, outperforming the fully supervised baseline in robustness despite having far less labeled data.
  • Model Size Impact: As shown in Figure 3, increasing the ALBERT model size from 12M to 235M parameters drastically reduced the performance gap, though the "relative drop" (bar charts) remains a challenge for smaller models.
Figure 3: Variation in in-domain (Org; solid) and ad- versarial performance (Adv; dash-dotted) in terms of accuracy with respect to the model size, for SST-2 and MNLI-m. We also show the variation in the relative per- centage drop in accuracy given by (org −adv)/org %) using bar charts.

Limitations and Future Work

The authors acknowledge several limitations:

  1. Black-box Attacks: Because AdvGLUE uses pre-constructed examples, the attacks weren't tailored to the specific gradients of the models being tested. Future work should explore "white-box" attacks.
  2. Hyperparameter Tuning: To maintain a "true" few-shot setting, the authors avoided extensive tuning on a development set, which might have yielded even better results.
  3. Computational Cost: While iPET and PET are robust, they are more expensive to train and run (due to ensembling and iterative training) than vanilla prompting.

Broadly, this work serves as a warning and a guide: while prompt-based learning is efficient, developers must look beyond simple accuracy and consider the "hidden" costs of ensuring these models are safe from adversarial manipulation.

Summary updated

Abstract

State-of-the-art few-shot learning (FSL) methods leverage prompt-based fine-tuning to obtain remarkable results for natural language understanding (NLU) tasks. While much of the prior FSL methods focus on improving downstream task performance, there is a limited understanding of the adversarial robustness of such methods. In this work, we conduct an extensive study of several state-of-the-art FSL methods to assess their robustness to adversarial perturbations. To better understand the impact of various factors towards robustness (or the lack of it), we evaluate prompt-based FSL methods against fully fine-tuned models for aspects such as the use of unlabeled data, multiple prompts, number of few-shot examples, model size and type. Our results on six GLUE tasks indicate that compared to fully fine-tuned models, vanilla FSL methods lead to a notable relative drop in task performance (i.e., are less robust) in the face of adversarial perturbations. However, using (i) unlabeled data for prompt-based FSL and (ii) multiple prompts flip the trend. We further demonstrate that increasing the number of few-shot examples and model size lead to increased adversarial robustness of vanilla FSL methods. Broadly, our work sheds light on the adversarial robustness evaluation of prompt-based FSL methods for NLU tasks.
BibTeX
@inproceedings{nookala2023adversarial,
  author = {Venkata Prabhakara Sarath Nookala and Gaurav Verma and Subhabrata Mukherjee and Srijan Kumar},
  title = {{Adversarial Robustness of Prompt-based Few-Shot Learning for Natural Language Understanding}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.138},
}
Figure