PerturbScore: Connecting Discrete and Continuous Perturbations in NLP

Linyang Li, Ke Ren, Yunfan Shao, Pengyu Wang, Xipeng Qiu

Abstract

Robustness in Natural Language Processing (NLP) is traditionally difficult to quantify due to the discrete nature of text. Unlike Computer Vision, where continuous pixel perturbations have clear mathematical bounds, text edits lack a direct mapping to model output shifts. We present PerturbScore, a framework that bridges this gap by mapping discrete text perturbations to their equivalent continuous embedding norms. By training a regression-based PerturbScorer, we demonstrate that discrete edits can be objectively measured by the magnitude of the continuous noise required to produce an identical model response. Our results show that PerturbScore significantly outperforms traditional metrics like Edit Distance and BERTScore, achieving Spearman correlations above 0.9 with actual model shifts and providing new insights into the mechanics of adversarial training.

Introduction

In Computer Vision (CV), measuring model robustness is mathematically intuitive: one adds a small amount of continuous noise to pixels and measures the resulting impact on classification. In contrast, language is fundamentally discrete. Swapping one word for another—such as changing "good" to "great" versus "good" to "bad"—does not have a clear numerical distance that consistently correlates with model behavior.

Existing proxies like Edit Distance (character/word counts) or BERTScore (semantic similarity) are frequently used to estimate the "size" of a change, but they often fail to reflect how much a specific model's internal logic or output will actually shift. Furthermore, identifying the "worst-case" discrete perturbation is a combinatorial challenge due to the infinite variations of word swaps and insertions. PerturbScore addresses this by asking: Can we find a bridge that lets us treat discrete text changes as if they were continuous noise?

The PerturbScore Framework

The authors propose a framework to align discrete and continuous spaces based on three key assumptions:

  1. Effect Similarity: A discrete perturbation and a continuous one are considered equivalent if they induce the same magnitude of shift in the model’s output.
  2. Lipschitz Continuity: Small changes in the embedding space should result in bounded changes in the output.
  3. Quantifiable Mapping: For any discrete change, there exists a minimum continuous "norm-ball" (radius $\epsilon$) that mimics its effect.

The Workflow

To implement this, the researchers utilize a two-step process. First, they perform Quantification using Projected Gradient Descent (PGD). This search identifies the smallest continuous perturbation ($\delta$) with a norm $\epsilon$ that produces the same output shift as a specific discrete perturbation $P(S)$.

Second, to avoid the high computational cost of running PGD for every new sample, they develop the PerturbScorer. This is a fine-tuned transformer-based regression model trained to take the original text and its discrete perturbation as input and predict the equivalent continuous $\epsilon$. This score serves as a universal metric for perturbation intensity, grounded in the model's actual embedding space.

Experimental Setup

The framework was evaluated using two standard NLP benchmarks: IMDB (sentiment analysis) and AG’s News (topic classification). The researchers tested standard BERT models alongside FreeLB, a model specifically trained with adversarial techniques to enhance robustness. Discrete samples for training the PerturbScorer were generated using TextFooler (a targeted adversarial attack) and random word perturbations.

Key Insights and Results

Superior Correlation and Generalization

PerturbScore demonstrates a significantly higher alignment with actual model shifts than traditional metrics. While Edit Distance, BERTScore, and Universal Sentence Encoder (USE) typically hover between 0.5 and 0.7 in Kendall or Spearman correlation tests, PerturbScore consistently achieves a Spearman correlation of >0.9.

Notably, the metric exhibits strong generalization capabilities. A PerturbScorer trained on the IMDB dataset remained accurate when predicting perturbation intensity on AG’s News. Furthermore, a scorer trained on a standard BERT model could successfully predict shifts for the robustly-trained FreeLB model, suggesting the metric captures a fundamental relationship between text and embeddings.

Understanding Adversarial Training

The study provides a mathematical confirmation of why adversarial training is effective. Models like FreeLB exhibit a "tighter" connection between discrete and continuous perturbations. This suggests that adversarial training works by narrowing the gap between how a model perceives a semantic word swap versus a mathematical shift in its embeddings, effectively smoothing the model's manifold.

Quantifying Attack "Damage"

The results also highlight the disparity between random and adversarial changes. Adversarial attacks like TextFooler require much larger continuous "norm-balls" to mimic than random word swaps. PerturbScore allows researchers to quantify this "damage" precisely, providing a tool to study the messy, discrete world of text through the lens of continuous optimization.

Limitations and Future Directions

While PerturbScore offers a robust bridge between spaces, the authors note that the connection is currently empirical and heuristic rather than a strict mathematical proof. The current study focused on text classification; the applicability of these correlations to generative tasks, such as summarization or dialogue, remains an open question.

As the field transitions toward Large Language Models (LLMs), exploring how these massive architectures connect discrete and continuous spaces—especially in multi-modal contexts—will be a critical next step for robustness research.

Summary updated

BibTeX
@inproceedings{li2023perturbscore,
  author = {Linyang Li and Ke Ren and Yunfan Shao and Pengyu Wang and Xipeng Qiu},
  title = {{PerturbScore: Connecting Discrete and Continuous Perturbations in NLP}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.442},
}
Figure