Foundation reference

Adversarial Examples & Robustness

Adversarial examples show that a model can be accurate on ordinary inputs while relying on features that tiny, targeted changes can flip; Ilyas et al. (2019) argue that these are real but non-robust features of the data.

Concept 44 of 100TheoryStudy phase 8
Key equation
xadv=x+ϵ⋅sign(∇xL)x_{\text{adv}} = x + \epsilon \cdot \text{sign}(\nabla_x L)
Reading map and next steps

Study guide

Where to start

Concept 44 of 100Adversarial ExamplesTheory · Study phase 8: Scaling, theory & multimodal
Question

How much of adversarial vulnerability comes from high dimensionality, where many tiny changes add up, and how much from what the model has learned?

How to study this pagePredict · Check · Generalize · Continue
PredictSay what you expect.

Pick a concrete input and say what the equation should give before you read the math.

CheckCheck against the math and the papers.

Work through the math, then read the cited papers for the original argument.

GeneralizeName what stays the same.

Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.

ContinueFollow the connections.

Use the prerequisites and related concepts at the end of the page to fill the next gap.

Why It Matters for Modern Models

  • Adversarial examples show that a model can be accurate on ordinary inputs while relying on features that tiny, targeted changes can flip; Ilyas et al. (2019) argue that these are real but non-robust features of the data.
  • The same idea carries over to language models, where optimized adversarial suffixes can make aligned chat models produce content they would normally refuse (Zou et al., 2023).
  • Adversarial training with PGD has held up against later, stronger attacks better than most proposed defenses, at a cost in accuracy on clean inputs (Madry et al., 2018; Athalye et al., 2018).

Questions to Think About

  • Why are even linear models vulnerable, as Goodfellow et al. (2015) argued: how does a tiny change in every coordinate add up to a large change in a dot product?
  • On CIFAR-10, Madry et al. (2018) report 95.2% clean accuracy for a wide ResNet with standard training and 87.3% with PGD adversarial training; is some of this trade-off unavoidable, as Tsipras et al. (2019) argue?

Core Math

Key Equation
xadv=x+ϵ⋅sign(∇xL)x_{\text{adv}} = x + \epsilon \cdot \text{sign}(\nabla_x L)

An adversarial example is an input x+δx + \delta whose perturbation δ\delta is too small to matter to a person (for images, often ∥δ∥∞≤8/255\|\delta\|_\infty \le 8/255) but changes the model's prediction (Szegedy et al., 2014).

FGSM (fast gradient sign method) takes one step in the direction that increases the loss fastest within an ℓ∞\ell_\infty budget ϵ\epsilon (Goodfellow et al., 2015):

xadv=x+ϵ⋅sign(∇xL(θ,x,y))x_{\text{adv}} = x + \epsilon \cdot \text{sign}(\nabla_x L(\theta, x, y))

PGD (projected gradient descent) takes several smaller steps and projects back onto the allowed ball Bϵ(x)\mathcal{B}_\epsilon(x) after each one (Madry et al., 2018):

x(t+1)=ΠBϵ(x)(x(t)+α⋅sign(∇xL(θ,x(t),y)))x^{(t+1)} = \Pi_{\mathcal{B}_\epsilon(x)} \left( x^{(t)} + \alpha \cdot \text{sign}(\nabla_x L(\theta, x^{(t)}, y)) \right)

Adversarial training minimizes the loss on the worst perturbation the attack can find:

min⁡θE(x,y)[max⁡∥δ∥≤ϵL(θ,x+δ,y)]\min_\theta \mathbb{E}_{(x,y)} \left[ \max_{\|\delta\| \leq \epsilon} L(\theta, x + \delta, y) \right]

Key Papers

Intriguing properties of neural networks

Szegedy et al.2014ICLR
Read paper →

Explaining and Harnessing Adversarial Examples

Goodfellow, Shlens & Szegedy2015ICLR
Read paper →

Towards Deep Learning Models Resistant to Adversarial Attacks

Madry et al.2018ICLR
Read paper →

Robustness May Be at Odds with Accuracy

Tsipras et al.2019ICLR
Read paper →

Adversarial Examples Are Not Bugs, They Are Features

Ilyas et al.2019NeurIPS
Read paper →

Connections

Where to go next

Automated Red Teaming builds directly on Adversarial Examples.

Automated Red Teaming