On Sensitivity of Deep Learning Based Text Classification Algorithms to Practical Input Perturbations

Aamir Miyajiwala, Arnav Ladkat, Samiksha Jagadale, Raviraj JoshiSAI 2022

Abstract

Deep learning models for text classification, including CNNs, LSTMs, and BERT, often achieve state-of-the-art performance on clean, pre-processed datasets. However, their robustness to practical, non-adversarial input perturbations—such as the addition or removal of punctuation and stop words—remains understudied. This paper systematically evaluates the sensitivity of these architectures to discrepancies between training and testing data cleanliness. Our findings reveal significant performance gaps, with BERT showing particular vulnerability to token removal and LSTMs being more sensitive than CNNs to sequential disruptions.

Introduction

In the pursuit of state-of-the-art (SOTA) performance, researchers typically train and evaluate models on "clean" datasets. These datasets undergo extensive pre-processing to remove "noise" such as punctuation, HTML tags, and stop words. However, real-world deployment environments are rarely so controlled. A model trained on meticulously cleaned data may encounter raw, messy text in production, or conversely, a model trained on raw data might be fed pre-processed text.

This study addresses the lack of systematic research into these practical input perturbations. Unlike malicious "adversarial attacks," these perturbations represent legitimate, everyday variations in text. The central question is: How robust are modern text classification algorithms when the "cleanliness" of the training data does not match the test data?

Methodology

The researchers employed a "black-box" evaluation approach across three popular architectures: CNNs (two convolutional layers), LSTMs (uni-directional, two layers), and BERT-base cased (pre-trained Transformer).

The proposed experimental pipeline for evaluating model sensitivity.

The experimental design simulated three primary scenarios of "train-test mismatch":

  1. Addition of tokens: Training on clean data and testing on raw (unclean) data.
  2. Addition of OOV (Out-Of-Vocabulary) tokens: Training on clean data and testing on raw data where extra tokens are mapped to an OOV tag.
  3. Removal of tokens: Training on raw data and testing on clean data.
Framework for evaluating robustness across mismatched training and test data cleanliness.

The "cleaning" process involved expanding contractions, removing special characters, lowercasing, and the optional removal of stop words (e.g., "the", "is", "at"). The study utilized four standard benchmarks: SST-2 (sentiment), TREC-6 (question classification), BBC News (topic), and TweetEval (Twitter sentiment).

Key Insights and Analysis

The BERT Paradox

Despite its dominance in Natural Language Understanding, BERT exhibits a unique sensitivity to the removal of tokens. As BERT is pre-trained on full, linguistically coherent sentences, removing "unimportant" stop words disrupts the structural context it relies on, leading to significant performance degradation.

Architectural Robustness

LSTMs were found to be more sensitive to perturbations than CNNs. The authors hypothesize that the sequential nature of LSTMs makes them more susceptible to being "tripped up" by unexpected tokens, whereas the local feature-extraction approach of CNNs provides a degree of inherent buffer.

The Impact of Stopword Removal

On short-text datasets like TREC-6, where sentences average only 10 tokens, removing stop words can leave as few as two tokens. This "over-cleaning" results in a massive accuracy drop (e.g., from ~83% to ~60% for a CNN) because the model loses critical context.

Embedding Strategies

Models utilizing trainable word embeddings proved significantly more robust than those using static embeddings. Finetuning allows the model to adapt its internal representations to the specific "noise" present in the training set, mitigating the impact of perturbations.

Conclusion

This research highlights a critical "robustness gap" in modern NLP models. While highly effective on clean data, models like BERT and LSTMs are surprisingly fragile when faced with simple variations in text cleanliness. Future work should expand this framework to include spelling errors, typos, and grammatical shifts, while exploring automated methods to make models "perturbation-aware" during training.

Summary updated

BibTeX
@inproceedings{miyajiwala2022sensitivity,
  author = {Aamir Miyajiwala and Arnav Ladkat and Samiksha Jagadale and Raviraj Joshi},
  title = {{On Sensitivity of Deep Learning Based Text Classification Algorithms to Practical Input Perturbations}},
  booktitle = {SAI},
  year = {2022},
  doi = {10.1007/978-3-031-10464-0\_42},
}
Figure