Neutralizing Adversarial Perturbations through Inference Time Purification

This direction is no longer present in the current build. Its last version stays readable and citable here.

Version 1 of 136 papers52 conceptsfrozen 2026-10-04

Modern transformer-based models, from Large Language Models (LLMs) to Vision Transformers (ViTs), share a common vulnerability: they are often "brittle." Small, carefully crafted perturbations—whether they are synonym swaps in a sentence or patches in an image—can hijack a model's internal representations, leading to jailbreaks or misclassifications.

Rather than attempting the computationally expensive task of retraining models to be inherently robust, a growing body of research suggests a more surgical approach: Inference-Time Purification. The core intuition is that adversarial triggers are "unnatural" high-influence signals that can be identified, stripped away, or "washed out" before the model ever makes a final decision.

Identifying the Malicious Signal

The first step in purification is distinguishing between essential semantic content and adversarial noise. Adversarial tokens often leave distinct "fingerprints" in the model's internal state.

Xuanli He and colleagues in IMBERT demonstrate that malicious triggers often produce abnormal spikes in gradients and self-attention scores. By setting a threshold for these signals, the system can pinpoint tokens that are exerting an outsized, suspicious influence on the output. Similarly, Anindya Sundar Das and the authors of X-GRAAD use a combined gradient-attention anomaly score to "unmask" backdoors without needing to know the trigger in advance.

A more theoretical approach is taken by Jiang Bian and the team behind IBProtector. They apply the Information Bottleneck principle, using a lightweight auxiliary model to generate a mask. This mask preserves only the most informative tokens for the task at hand, effectively filtering out the "noise" of a jailbreak attempt while keeping the core query intact.

Purification via Masking and Reconstruction

Once suspicious tokens or regions are identified, the defense must neutralize them. The most direct method is sanitization: removing or masking the offending tokens.

In the vision domain, Liang Liu and collaborators show that masking anomalous patches in a Vision Transformer and then performing a second inference pass can restore accuracy. This "re-run" strategy prevents the model from being distracted by the adversarial patch.

In natural language, simply deleting tokens can break the grammatical structure. To solve this, Linyang Li and Xipeng Qiu propose Text Adversarial Purification. Their framework uses a Masked Language Model (MLM) like BERT to "fill in the blanks." By randomly masking tokens and asking the MLM to reconstruct them, the system replaces brittle adversarial word substitutions with contextually natural synonyms, effectively "washing away" the attack. Zhaoyang Wang explores a similar path with RMLM, treating the input as a "moving target" through random swaps and reconstruction to ensure the classifier only sees "clean" text.

Defocusing through Controlled Noise

An alternative to removing tokens is to disrupt the specific, fragile configuration the attacker relies on. This is known as Reactive Perturbation Defocusing (RAPID).

Heng Yang and Ke Li argue in their work that the best defense is a "counter-attack." When an adversarial input is detected, RAPID injects its own "safe" perturbations. This secondary noise "defocuses" the malicious strike, nudging the model's internal representation back toward the original semantic space.

This works because adversarial attacks are often highly optimized for a specific path through the model's decision boundaries. By introducing controlled, non-malicious noise—such as character-level jitter or synonym swaps—the defense breaks the precise alignment required for the attack to succeed. Han Cheol Moon and Shafiq Joty formalize this in RSMI, using randomized smoothing and gradient-guided masking to force the model to derive meaning from the broader context rather than individual, potentially manipulated tokens.

Why It Works: The Semantic Buffer

The success of these methods across different modalities suggests a shared underlying principle: semantic redundancy.

Natural language and images contain significant redundancy. A sentence's meaning is rarely dependent on a single specific word, and an image's subject is rarely defined by a single patch. Adversarial attacks exploit this by concentrating influence into a few "brittle" points.

Purification techniques—whether they are restoring background tokens to dilute triggers as in SAP by Shuailong Wang, or inverting malicious feature vectors as in LMSanitator by Chengkun Wei—all aim to restore the "semantic buffer." By forcing the model to rely on the global context rather than local perturbations, these defenses align machine processing more closely with human-like robust comprehension.

Papers in this version

History & citationVersion 1 · 2026-10-04

No longer present in the current build · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_neutralizing_adversarial_perturbations_t_8755716c,
  title = {Neutralizing Adversarial Perturbations through Inference Time Purification},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/neutralizing-adversarial-perturbations-through-inference-time-purification/rdr_8755716c7f4548f3bd81cf823a95822c},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-12-03},
}

This exact version (version 1, frozen text):

@misc{lacuna_neutralizing_adversarial_perturbations_t_8755716c_v1,
  title = {Neutralizing Adversarial Perturbations through Inference Time Purification},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/neutralizing-adversarial-perturbations-through-inference-time-purification/rdr_8755716c7f4548f3bd81cf823a95822c/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-12-03},
}