Subscribe
AI
7 min read

What Is an Adversarial Example? The Tiny Input Change That Flips What AI Sees

An adversarial example is an input that has been changed in a way so small a human cannot notice it, but that makes a machine learning model answer confidently and wrongly. Nicholas Carlini's version of the stock example: a neural network labels a photo of a tabby cat "cat" with 88% confidence. Add a carefully chosen smear of noise that is essentially invisible to the eye. The same model now labels the image "guacamole" with 99% confidence (Carlini, FAR.AI talk). That is the whole phenomenon. N

What Is an Adversarial Example? The Tiny Input Change That Flips What AI Sees

An adversarial example is an input that has been changed in a way so small a human cannot notice it, but that makes a machine learning model answer confidently and wrongly. Nicholas Carlini's version of the stock example: a neural network labels a photo of a tabby cat "cat" with 88% confidence. Add a carefully chosen smear of noise that is essentially invisible to the eye. The same model now labels the image "guacamole" with 99% confidence (Carlini, FAR.AI talk).

That is the whole phenomenon. No hack, no exploit, no broken code. The model looks at a normal input, computes normally, and is wrong with high confidence. Adversarial examples are the oldest and still least solved failure mode of modern machine learning, and the logic behind them now powers the jailbreak industry for large language models.

The discovery: blind spots found by optimization

In December 2013, Christian Szegedy and colleagues at Google Brain published "Intriguing Properties of Neural Networks", the paper that named the effect. The researchers ran standard image classifiers backward: instead of training weights to fit fixed images, they held the weights fixed and optimized the input, using a numerical optimizer (L-BFGS) to find the smallest change to a correctly classified image that made it misclassified. They reported two unsettling findings. First, on datasets like ImageNet the perturbations were small enough to be "hardly perceptible" to humans while flipping the prediction. Second, the same adversarial image often fooled other networks too, even ones with different architectures, different hyperparameters or trained on different subsets of the data.

That second property, transferability, is what turns an academic curiosity into a security problem. An attacker does not need the target model. They can build their own cheap model, optimize against it, and throw the result at a system they cannot see inside.

Panda plus noise equals gibbon

The follow-up paper that made the attack cheap is Ian Goodfellow, Jonathon Shlens and Szegedy's "Explaining and Harnessing Adversarial Examples" (2014). The authors proposed that the cause is not exotic nonlinearity but the opposite: neural networks behave too linearly. A digital image has millions of pixels. A perturbation of 0.007 per pixel looks like nothing in any single pixel, but summed across a million dimensions in the direction of the gradient, it is a large change to the model's score.

Their method, the Fast Gradient Sign Method (FGSM), needs one backward pass and nothing else. The paper's famous figure: a panda classified at 57.7% confidence, plus an epsilon of 0.007 times the sign of the gradient, becomes a gibbon at 99.3% confidence. The perturbation itself looks like faint television static.

The authors also drew the conclusion the field has not escaped: ordinary training builds classifiers that work on a "very thin manifold encompassing the training data," in their words, calling the result "a Potemkin village that works well on naturally occurring data, but is exposed as a fake" once you probe nearby points. Test-set accuracy, they argued, says nothing about behavior off the data distribution.

Two framed geometric cat portraits side by side; the right one carries a faint dotted static overlay

Why they exist: features that only machines can see

The best answer so far came from MIT's Madry lab in 2019, "Adversarial Examples Are Not Bugs, They Are Features". Andrew Ilyas and colleagues trained models on datasets stripped down to look like pure noise to humans, and the models generalized normally. The takeaway: real training data contains patterns, called non-robust features, that are genuinely predictive of the label yet incomprehensible and brittle from a human point of view. A standard model learns them because they are in the data and they help on the test set. An adversarial example is not a glitch injected into the model; it is an amplification of knowledge the model legitimately extracted from the world. The mismatch is that human robustness and statistical usefulness point in different directions.

It left the screen

The same recipe works on anything differentiable, which includes the physical world. Researchers covered a real stop sign with an adversarial poster, or added two small rectangular stickers, and a state-of-the-art object detector (YOLO v2) missed the sign in over 85% of frames in lab video; outdoors, the poster worked on 72.5% of frames and the stickers on 63.5%. The perturbation transferred to a different detector, Faster R-CNN, that was never used to craft it.

Speech recognition is equally exposed. Carlini et al. showed in 2016 that ordinary recorded speech, modified adversarially, becomes unintelligible to human listeners while commercial speech recognition systems transcribe it as the attacker's chosen command. The 2018 "DolphinAttack" pushed further: voice commands hidden on an ultrasonic carrier above 20 kHz, inaudible to every person in the room, recovered by the nonlinearity of cheap microphone circuits and executed by Siri, Google Now, Cortana and Alexa.

A flat street scene with a blank octagonal sign bearing two small sticker patches; a dashed detection frame encloses the car and bicycle but not the sign

A decade of defenses, and why none of them won

Most proposed defenses have met the same end. Carlini and Wagner's 2016 paper "Towards Evaluating the Robustness of Neural Networks" is the classic case study: defensive distillation had been reported to cut attack success from 95% to 0.5%, and their optimization attack broke it at essentially 100% success. The paper's enduring methodological rule is that a defense is only as good as the strongest adaptive attack used against it. Madry et al. (2017) formalized the strong attack as projected gradient descent (PGD) and showed adversarial training against it gives the best robustness known, but the guarantee only covers perturbations up to a fixed size, and robustness costs clean accuracy. Carlini's 2024 retrospective on the field is blunt: after thousands of papers, defenses remain limited, and no method stops a determined attacker who can iterate.

The text version: jailbreaks are adversarial examples

LLM jailbreaks inherited the mechanism, and the 2013 findings replay almost word for word. In July 2023, Zou et al. published the Greedy Coordinate Gradient (GCG) attack: automatic optimization over tokens finds a short adversarial suffix that, appended to a harmful request, maximizes the probability the model answers affirmatively instead of refusing. Just as in 2013, the suffix trained on open models transferred to closed ones: the authors demonstrated it induced objectionable content through the public interfaces of ChatGPT, Bard and Claude. One suffix optimized across behaviors also worked on 84% of held-out harmful behaviors on Llama-2, in the paper's evaluation.

Long context added a second variant. Anthropic's "many-shot jailbreaking" (2024) placed hundreds of fake question-and-answer dialogues, in which a helpful assistant complies with harmful requests, inside a single prompt; models including Claude 2.0, GPT-3.5, GPT-4, Llama-2 and Mistral followed the pattern, and attack success scaled with the number of demonstrations, a paper version of in-context learning turned against the alignment.

The good news, for once, is that text defenses currently hold better than image defenses. The same gradient-optimized suffixes that transfer between models read as gibberish to a perplexity filter, and a 2023 baseline-defense study found such filters reduce GCG attack success to zero on open models, at the price of flagging roughly one in ten ordinary user prompts, which the authors judged untenable on its own. Anthropic reported that a pipeline that classifies the prompt and rewrites it before generation cut many-shot attack success from 61% to 2%. The defenses work because language, unlike pixels, has a visibility threshold: attack strings optimized in token space tend to look wrong to both humans and detectors. Optimizers for discrete text are also weaker than gradient descent on continuous inputs, though that gap is closing as attackers use the model itself to rewrite jailbreaks into fluent prose.

What to take away

  • Adversarial examples exist because models are trained to fit statistical patterns in data, and some predictive patterns are invisible and brittle to humans. That was shown in 2013 and reconfirmed as "features, not bugs" in 2019.
  • They transfer. An attack built on one model frequently works on models you cannot inspect, so the attacker never needs your weights.
  • High accuracy does not mean robustness. A classifier can score 99% on the test set and flip on an input no human can distinguish from a correct one.
  • No general defense has survived. Adversarial training, distillation, and detection filters all buy margin, not immunity; evaluation against adaptive attacks is the only honest test.
  • LLM jailbreaks are adversarial examples in text: optimized suffixes (GCG) and long-context demonstrations (many-shot) are the same idea applied to alignment instead of classification.
  • The asymmetry favors attackers. One gradient step is cheaper than one defense, and it has been for thirteen years.

Sources

AILLMEducation