Backdoor Samples Detection Based on Perturbation Discrepancy Consistency in Pre-trained Language Models

Zuquan Peng, Jianming Fu, Lixin Zou, Li Zheng, Yanzhen Ren, Guojun Peng · DOI · OpenReview

Abstract

The use of unvetted third-party and internet data renders pre-trained models susceptible to backdoor attacks. Detecting backdoor samples is critical to prevent backdoor activation during inference or injection during training. However, existing detection methods often require the defender to have access to the poisoned models, extra clean samples, or significant computational resources, limiting their practicality. To address this, we propose NETE (perturbatioN discrEpancy consisTency Evaluation), a novel zero-shot, black-box detection method. NETE identifies backdoor samples by measuring the consistency of perturbation discrepancies using curvature evaluation. Experiments across various backdoor attacks demonstrate that NETE outperforms existing zero-shot black-box detection methods.

Introduction: The Threat of Backdoor Attacks

Pre-trained language models (PLMs) are increasingly built using massive datasets scraped from the internet. This reliance on unvetted data makes them prime targets for backdoor attacks. In these scenarios, an adversary injects a "trigger" into the training data—ranging from simple rare words to complex linguistic styles. When the model encounters this trigger during inference, it switches from normal behavior to a malicious target behavior.

Examples of backdoor trigger schemes across different levels of complexity.

Existing defenses often suffer from a "usability gap." Most require white-box access to model weights, a large set of clean reference samples, or massive computational budgets. This is impractical for users of "Machine Learning as a Service" (MLaaS) who only have API access. Furthermore, as triggers evolve from simple word-level insertions to sophisticated "style" triggers (e.g., Shakespearean prose), traditional frequency-based filters are becoming obsolete.

The NETE Framework

To bridge this gap, we introduce NETE, a detection pipeline that relies on a phenomenon called Anomalous Perturbation Discrepancy Consistency (PDC). Unlike previous methods, NETE is model-agnostic and requires no clean samples or access to the poisoned model's internals.

Comparison of NETE against existing defense methods in terms of requirements and goals.

The NETE method follows three main steps:

  1. Perturbation Generation: Using an off-the-shelf "filler" model (like T5), the system masks 10% of the input tokens and fills them back in based on context, creating multiple slightly varied versions of the input.
  2. Consistency Testing: A standard pre-trained model (like GPT-2) calculates the log probability of the original sample and its perturbed versions.
  3. Curvature Evaluation: NETE measures the curvature of the probability space using a finite-difference approximation of the Hessian matrix trace.

The core insight is that clean samples are "fragile"—small linguistic changes lead to significant swings in log probability. In contrast, backdoor samples are dominated by the trigger's influence, making their probability scores unusually "consistent" or "robust" across perturbations. If the measured curvature is below a certain threshold, the sample is flagged as a backdoor.

Experimental Evaluation

We evaluated NETE across several real-world benchmarks, including YELP (sentiment analysis), OLID (toxic language detection), and COVID (fake news detection). We also tested complex reasoning tasks like MATH and StrategyQA to assess "jailbreak" and "instruction-following" attacks.

Key Results

  • Superior Performance: NETE consistently outperformed existing zero-shot methods like ONION and STRIP, achieving an AUROC of 0.90 to 0.98, particularly for syntactic and style-based attacks.
  • Efficiency: Stable detection accuracy is reached with only 50 perturbation steps, making it viable for near real-time filtering.
  • Versatility: Beyond backdoors, NETE proved effective at detecting adversarial examples and jailbreak attempts, achieving an AUROC of 0.91 for the latter.

Discussion and Insights

The most striking finding is that backdoor triggers effectively create "islands of stability" or "low curvature" regions in the model's probability landscape. Because the model is so strongly tuned to the trigger, it ignores natural linguistic variations around it. This makes NETE particularly effective against "style" triggers, which represent a global, non-linear shift clearly visible in curvature analysis.

While NETE is efficient compared to retraining, it still requires multiple forward passes per input, which may introduce latency in high-throughput environments. Additionally, while NETE excels at detection, correcting these samples—removing the trigger while preserving meaning—remains a significant challenge for future research.

Summary updated

BibTeX
@article{peng2025backdoor,
  author = {Zuquan Peng and Jianming Fu and Lixin Zou and Li Zheng and Yanzhen Ren and Guojun Peng},
  title = {{Backdoor Samples Detection Based on Perturbation Discrepancy Consistency in Pre-trained Language Models}},
  journal = {Neural Networks},
  year = {2025},
  doi = {10.1016/j.neunet.2025.108025},
}
Figure