Automated Robustness Testing for LLM-based NLP Software

Pengcheng Zhang (张鹏程), Mingxuan Xiao, Yan Xiao, Shunhui Ji, Hanbo Cai, Lei Xue, Pengcheng ZhangarXiv 2024 · DOI

Abstract

Large Language Models (LLMs) are increasingly integrated into NLP software, yet their robustness remains a critical concern. This paper introduces AORTA, an automated framework for stress-testing LLM-based applications, powered by a novel Adaptive Beam Search (ABS) algorithm. AORTA identifies subtle input perturbations that cause model failures with high efficiency and naturalness. Our evaluation across multiple datasets and models demonstrates an 86% success rate in finding vulnerabilities while significantly reducing computational costs compared to existing methods.

Introduction

As Large Language Models (LLMs) like ChatGPT and Llama become the backbone of modern NLP software—handling tasks from financial sentiment analysis to content moderation—their robustness is under scrutiny. Unlike traditional software, LLM-based applications rely on a combination of prompts (instructions) and examples (data) as inputs.

The primary challenge lies in the unpredictable nature of these "black box" models. Subtle, seemingly harmless changes to an input—such as swapping "want" for "hope"—can cause a model to produce incorrect labels or hallucinate, even when the underlying meaning remains unchanged.

Subtle perturbations in prompts and examples can lead to significant shifts in LLM output labels and confidence scores.

Existing testing tools designed for smaller Deep Neural Networks (DNNs) struggle with the scale of LLMs and the complex interaction between prompts and examples. There is a critical need for a testing framework that is both effective at identifying these "blind spots" and efficient enough to minimize API query costs.

The AORTA Framework

To address these challenges, we present AORTA (AutOmated Robustness Testing frAmework), a modular system designed to treat the search for vulnerabilities as a combinatorial optimization problem.

The AORTA framework consists of preparation stages and a testing method creation phase involving goal functions, perturbations, and search methods.

AORTA is composed of four primary components:

  1. Goal Function: Defines the criteria for a "failed" test (e.g., a label flip).
  2. Perturbations: Specifies how to modify the text (e.g., synonym replacement, word swapping).
  3. Constraints: Ensures the generated text remains readable and grammatically correct.
  4. Search Method: The algorithm used to navigate the space of possible perturbations.

Adaptive Beam Search (ABS)

The core "engine" of AORTA is Adaptive Beam Search (ABS). While standard greedy searches often fail to find optimal perturbations and meta-heuristic searches are too slow for LLMs, ABS introduces two key innovations:

  • Adaptive Beam Width: The algorithm dynamically adjusts the number of paths explored based on the success of current perturbations, saving time when paths are unproductive.
  • Backtracking: If a search path hits a dead end, ABS can revert to a previous "best" state to explore alternative directions, preventing the algorithm from getting trapped in local optima.

Experimental Evaluation

We evaluated AORTA using three diverse text classification datasets: Financial Phrasebank (FP) for sentiment analysis, AG’s News for topic categorization, and Movie Reviews (MR) for sentiment polarity. These were tested against five prominent open-source models: Mistral-7b, Llama-2-13b, Internlm2-20b, Yi-34b, and Llama-2-70b.

Key Results

  • Effectiveness: ABS achieved an average test success rate of 86.14%, significantly outperforming the previous state-of-the-art baseline, PWWS (~68%).
  • Efficiency: ABS reduced computational overhead by up to 3,441 seconds per successful test case and required 218 times fewer queries on average than baseline methods.
  • Quality and Naturalness: Test cases generated by ABS maintained high linguistic quality, with the lowest rate of grammatical errors (5.8 per case), ensuring vulnerabilities represent real-world risks.
  • Transferability: Robustness flaws identified in smaller models often persisted in larger models (e.g., from Llama-2-13b to Llama-2-70b), suggesting these vulnerabilities are inherent to LLM language processing.

Conclusion

AORTA and the ABS algorithm provide a scalable, efficient, and effective solution for benchmarking the robustness of LLM-based NLP software. While currently focused on text classification, future work will extend the framework to generative tasks and multi-modal systems.

Summary updated

BibTeX
@misc{2024automated,
  author = {Pengcheng Zhang (张鹏程) and Mingxuan Xiao and Yan Xiao and Shunhui Ji and Hanbo Cai and Lei Xue and Pengcheng Zhang},
  title = {{Automated Robustness Testing for LLM-based NLP Software}},
  year = {2024},
  eprint = {2412.21016},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.21016},
}
Figure