Skip to main content
QUICK REVIEW

[Paper Review] Defending Pre-trained Language Models as Few-shot Learners against Backdoor Attacks

Zhaohan Xi, Tianyu Du|arXiv (Cornell University)|Sep 23, 2023
Adversarial Robustness in Machine LearningComputer Science12 citations
TL;DR

The paper introduces MDP, a lightweight, plug-in defense that detects backdoor poisoning in prompt-based, few-shot PLMs by measuring how poisoning affects masking sensitivity using distribution anchors from few-shot data.

ABSTRACT

Pre-trained language models (PLMs) have demonstrated remarkable performance as few-shot learners. However, their security risks under such settings are largely unexplored. In this work, we conduct a pilot study showing that PLMs as few-shot learners are highly vulnerable to backdoor attacks while existing defenses are inadequate due to the unique challenges of few-shot scenarios. To address such challenges, we advocate MDP, a novel lightweight, pluggable, and effective defense for PLMs as few-shot learners. Specifically, MDP leverages the gap between the masking-sensitivity of poisoned and clean samples: with reference to the limited few-shot data as distributional anchors, it compares the representations of given samples under varying masking and identifies poisoned samples as ones with significant variations. We show analytically that MDP creates an interesting dilemma for the attacker to choose between attack effectiveness and detection evasiveness. The empirical evaluation using benchmark datasets and representative attacks validates the efficacy of MDP.

Motivation & Objective

  • Motivate the study of backdoor threats to prompt-based PLMs in few-shot settings.
  • Propose a defense tailored to few-shot prompts that does not require retraining or large datasets.
  • Leverage masking sensitivity differences between clean and poisoned samples to detect backdoors.
  • Optional enhancement to optimize prompts for masking-invariance to improve detection.
  • Demonstrate effectiveness across multiple datasets and backdoor attacks.

Proposed method

  • Formulate MDP as a masking-sensitivity detector using limited few-shot data as distributional anchors.
  • Represent each anchor by the PLM’s full language-modeling distribution over vocabulary tokens.
  • Compute the KL-divergence-based coordinates of test samples against anchors to quantify masking sensitivity.
  • Use Kendall rank correlation to measure how sample representations shift under masking.
  • Optionally optimize the prompt with a masking-invariance loss to strengthen clean-sample stability.
  • Provide a theoretical justification showing a trade-off between attack effectiveness and detection evasiveness for attackers.
Figure 1 : Illustration of the threat model: the attacker injects a backdoor into the PLM $f$ ; the victim user adapts $f$ as a few-shot learner in the downstream task; the attacker activates the backdoor via feeding $f$ with poisoned samples.
Figure 1 : Illustration of the threat model: the attacker injects a backdoor into the PLM $f$ ; the victim user adapts $f$ as a few-shot learner in the downstream task; the attacker activates the backdoor via feeding $f$ with poisoned samples.

Experimental results

Research questions

  • RQ1Can few-shot PLMs be defended against textual backdoor attacks without retraining or large datasets?
  • RQ2Does masking-sensitivity, anchored by few-shot data, distinguish poisoned from clean samples in prompt-based learning?
  • RQ3How does prompt optimization for masking invariance affect defense performance?
  • RQ4What theoretical limits govern the attacker’s ability to evade detection under MDP?

Key findings

  • MDP achieves lower false acceptance rates (FAR) and false rejection rates (FRR) than baselines across five datasets and multiple attacks.
  • MDP shows near-perfect defense against the SOS attack on SST-2 and CR datasets in several cases.
  • Using anchors from as few as 16 examples per class yields strong detection performance, with FAR/fPRR advantages over STRIP, ONION, and RAP.
  • Masking-invariance optimization improves clean-sample stability without sacrificing downstream task performance.
  • An analytical result demonstrates a fundamental trade-off for attackers between backdoor effectiveness and evasion of detection under MDP.
  • Continuous prompts outperform discrete prompts for MDP effectiveness.
Figure 2 : Overview of MDP: it detects a given sample ${X}_{\mathrm{in}}^{\mathrm{test}}$ as poisoned or clean by measuring the variation of its representational change with respect to a set of distributional anchors ${\mathcal{A}}$ .
Figure 2 : Overview of MDP: it detects a given sample ${X}_{\mathrm{in}}^{\mathrm{test}}$ as poisoned or clean by measuring the variation of its representational change with respect to a set of distributional anchors ${\mathcal{A}}$ .

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.