ROIC-DM: Robust Text Inference and Classification via Diffusion Model

Shilong Yuan, Wei Yuan, Hongzhi Yin, Tieke HearXiv 2024 · DOI

Introduction

Large Language Models (LLMs) have demonstrated remarkable capabilities across various NLP tasks but remain susceptible to adversarial attacks. Minor, often imperceptible perturbations—such as synonym replacement—can drastically alter model predictions. ROIC-DM addresses this "glass jaw" by repurposing diffusion models, typically used for generation, as inherently robust classifiers.

Methodology: Classification as Denoising

ROIC-DM introduces a novel paradigm where classification is treated as a reverse diffusion process. Unlike traditional text purification methods that attempt to "clean" the input text, ROIC-DM applies diffusion to the categorical labels themselves.

Overview of the ROIC-DM framework showing the diffusion/reverse process and model architecture.

The framework consists of three primary components:

  1. Diffusion on Labels: Gaussian noise is added to label vectors during the forward phase.
  2. Reverse Process Classification: The model starts with pure noise and iteratively denoises it to recover the correct label, conditioned on the input text $x$.
  3. The Advisor Mechanism: A fine-tuned language model (e.g., BERT) acts as an "advisor," providing soft-label probability distributions. This auxiliary information guides the noise estimator $f_\theta$, enhancing both efficiency and accuracy.

Experimental Evaluation

The model was evaluated on three benchmarks: AG NEWS (news classification), SST-2 (sentiment analysis), and MRPC (paraphrase detection). Robustness was tested against two potent adversarial attacks: TextFooler and BERT-Attack.

Key Results

ROIC-DM achieves a significant breakthrough in Accuracy under Attack (Aua%) while maintaining high performance on clean data.

Comparative performance of ROIC-DM against baseline models under adversarial attacks.

As shown in the results, on the AG NEWS dataset, a standard BERT model's accuracy drops to 20.5% under TextFooler. In contrast, ROIC-DM maintains 78.7% accuracy. Notably, the framework often improves clean accuracy; for instance, reaching 95.1% on AG NEWS compared to BERT's 94.0%.

Discussion and Insights

The inherent robustness of ROIC-DM stems from the diffusion model's training objective: recovering signal from noise. By learning the entire data distribution rather than just a decision boundary, the model becomes significantly harder to deceive. Furthermore, the "Advisor" mechanism proves that LLMs are highly effective as auxiliary information sources in adversarial environments, even if they are vulnerable as standalone decision-makers.

Limitations and Future Work

The primary trade-off for this robustness is inference speed. Because diffusion is an iterative process (requiring up to $T=1000$ steps), predictions are slower than standard single-pass transformers. Future research will focus on optimizing sampling efficiency and extending this framework to more complex hybrid tasks.

Summary updated

BibTeX
@misc{yuan2024roic,
  author = {Shilong Yuan and Wei Yuan and Hongzhi Yin and Tieke He},
  title = {{ROIC-DM: Robust Text Inference and Classification via Diffusion Model}},
  year = {2024},
  eprint = {2401.03514},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2401.03514},
}
Figure