CERT-ED: Certifiably Robust Text Classification for Edit Distance

Zhuoqun Huang, Neil G. Marchant, Olga Ohrimenko, Benjamin I. P. Rubinstein

Introduction

Deep learning models for Natural Language Processing (NLP) are notoriously fragile. Attackers can often flip a model's prediction—for instance, changing a "Spam" classification to "Not Spam"—by making minor, human-imperceptible changes to the text. While many empirical defenses exist, they are frequently bypassed by new, adaptive attack methods.

To address this, researchers have turned to certified robustness, which provides a mathematical guarantee that a model’s prediction will remain constant within a specific "radius" of input changes. However, most existing NLP certificates are limited to Hamming distance (simple word substitutions). CERT-ED (Certified Edit Distance) addresses this gap by providing the first framework to certify against the full Edit Distance (Levenshtein distance), covering insertions, deletions, and substitutions.

Methodology: Randomized Deletion Smoothing

CERT-ED utilizes a technique called Randomized Smoothing. Instead of classifying a single input $x$, the system generates thousands of "noisy" versions of that input, passes them through a base classifier, and determines the final prediction via a majority vote.

The core innovation in CERT-ED is the use of Randomized Deletion as the noise mechanism. For every word in a sentence, the system independently decides to either keep it or delete it based on a fixed probability ($p_{del}$).

The CERT-ED framework generates smoothed inputs via randomized deletion to provide a certified prediction and radius against adversarial edits.

Key technical contributions include:

  1. Multi-class Extension: Extending the mathematical framework of deletion noise from binary tasks to handle any number of classes.
  2. Certified Cardinality: Introducing "certified cardinality" ($CC$) to measure the total volume of protected space, allowing for a fair comparison between defenses with different geometric properties (e.g., Hamming vs. Edit distance).

Experimental Evaluation

The researchers evaluated CERT-ED across five diverse English text datasets: AG-News (topic classification), IMDB (sentiment analysis), Spam-assassin (spam detection), and LUN & SatNews (fake news detection). These datasets represent high-stakes environments where adversarial robustness is critical.

Key Results and Insights

CERT-ED demonstrated significant improvements over the previous state-of-the-art baseline, RanMASK, in several key areas:

  • Superior Robustness Volume: The framework protects a significantly larger set of possible inputs. On the SatNews dataset, CERT-ED's certified cardinality was found to be up to 10 billion times larger than the baseline for the same level of accuracy.
  • Empirical Resistance: When tested against 10 different types of real-world attacks, CERT-ED improved empirical robustness in 38 out of 50 experimental settings.
  • Efficiency: CERT-ED is not only more robust but also faster, reporting a 3x speedup in prediction and certification compared to RanMASK.
Certified accuracy as a function of log cardinality, showing CERT-ED's superior robustness volume over RanMASK.

The method is particularly effective on longer texts, such as news articles or emails, where the model can afford to lose some words to deletion noise without losing the overall semantic context.

Limitations and Future Work

Despite its strengths, CERT-ED faces challenges with very short sequences. Deleting words from a 10-word sentence (like those in AG-News) is far more damaging to accuracy than deleting words from a 300-word article. Additionally, sentiment analysis remains difficult because a single word (e.g., "not") can flip the entire meaning; if the smoothing process deletes such a word, the ground-truth label may change.

Future research will focus on exploring more sophisticated noise types and reducing the computational overhead inherent in randomized smoothing methods, which require thousands of model passes for a single certified prediction.

Summary updated

BibTeX
@inproceedings{huang2024cert,
  author = {Zhuoqun Huang and Neil G. Marchant and Olga Ohrimenko and Benjamin I. P. Rubinstein},
  title = {{CERT-ED: Certifiably Robust Text Classification for Edit Distance}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.findings-emnlp.635},
}
Figure