Reasoning Robustness of LLMs to Adversarial Typographical Errors

Esther Gan, Yiran Zhao, Liying Cheng, Yancan Mao, Anirudh Goyal, Kenji Kawaguchi, Min-Yen Kan, Michael Shieh

TL;DR

While Large Language Models (LLMs) excel at complex reasoning via Chain-of-Thought (CoT) prompting, they are surprisingly fragile when faced with simple human typos. This paper introduces the Adversarial Typo Attack (ATA) algorithm, demonstrating that strategically placing just a few typographical errors can trigger a catastrophic cascade of errors in an LLM's intermediate reasoning steps. To help researchers evaluate this vulnerability, the authors release $R^2\text{ATA}$, a new benchmark showing that these adversarial typos easily transfer from small open-source models to degrade large, closed-source commercial systems.

What Problem Does This Paper Address?

When humans interact with AI chatbots, typos are inevitable—whether it's hitting an adjacent key, duplicating a letter, or adding an extra space. While previous research has explored how LLMs handle contextual biases (like leading instructions or irrelevant text), their robustness against non-contextual, surface-level typographical errors during multi-step reasoning remains understudied.

The authors address this gap by showing that typos are not always innocuous. In complex Chain-of-Thought (CoT) reasoning, a single typo can misdirect the model's attention mechanism. This causes a "butterfly effect" where early intermediate reasoning steps become corrupted, ultimately derailing the final answer.

Figure 1: There are two typing errors in the query: omis- sion of a letter (year becomes yar) and duplication of a letter (has becomes haas). Consequently, in Step 1 the model wrongly wrote Regina as A, while in Step 2 the text reverses the relationship between this year’s and last year’s written novel. These errors in intermediate steps lead to an incorrect final answer.

Methods

The authors propose the Adversarial Typo Attack (ATA), an optimization-based framework designed to find the most destructive typos for a given query.

Unlike standard adversarial attacks that try to force an LLM to output harmful content, ATA aims to break the model's reasoning flow while keeping the text natural and readable to humans. The algorithm works through an iterative process:

  1. Gradient-Based Selection: It computes gradients to identify the tokens (words) in the input query that most heavily influence the model's output.
  2. Typo Perturbation: For the top influential words, it samples realistic human typing mistakes from a predefined dictionary. These include four categories: Keyboard Proximity (hitting an adjacent key), Double-Typing (repeating a letter), Omission (skipping a letter), and Extra Whitespace.
  3. Loss Minimization: It evaluates the model's loss against a specific target refusal string: "Sorry, I'm unable to answer the question." By optimizing for this negative semantic target, the attack effectively coaxes the model into a state of confusion.

The candidate typo that results in the lowest loss (highest confusion) is selected, and the process repeats for a set number of iterations.

Figure 2: ATA mainly consists of three steps: 1 selecting a set of tokens with the highest gradients; 2 sampling typographical errors to edit the selected tokens and generate a batch of candidates; 3 evaluating the losses of the candidates using the model and retaining the optimal candidate for the next iteration.

Datasets

The authors evaluated their attack across three widely recognized reasoning benchmarks:

  • GSM8K: Grade-school math word problems.
  • BBH (BIG-bench Hard): Challenging tasks requiring multi-step symbolic and logical reasoning.
  • MMLU: A massive multitask language understanding dataset covering various academic subjects.

Using these datasets, they generated the $R^2\text{ATA}$ (Reasoning Robustness to ATA) benchmark. They applied ATA to smaller open-source models (like Mistral-7B) to generate perturbed questions, creating an evaluation set to test the "transferability" of these attacks on larger, black-box models.

Key Insights and Ideas

  • The Attention Shift: Visualization of attention weights revealed that when a critical word is altered (e.g., changing "much" to "muxh"), the LLM's attention completely drops from that token and shifts to irrelevant context words (like "the house"), breaking the logic chain.
  • The Power of Whitespace: Across all datasets, ATA frequently favored inserting extra whitespaces over character substitutions. This suggests that LLMs are highly sensitive to formatting anomalies, likely because multiple consecutive spaces are rare in clean training data.
Figure 4: Distribution of error operations selected by ATA across the datasaets in R2ATA benchmark. The predominance of whites- pace errors highlights a key vulnerability in LLMs.
  • Targeting Content Words: The attack heavily targets nouns (48.9%), verbs (16.7%), and adjectives (14.9%), while largely ignoring stop words. This shows that ATA strategically undermines the core semantic weight of the sentence.

Key Results

  • Direct Attack Impact: On the GSM8K math dataset, Mistral-7B-Instruct's accuracy plummeted from 43.7% to 38.6% with just a single character edit. With 8 edits, its performance was slashed by more than half, dropping to 19.2%.
  • Remarkable Transferability: Typos optimized on Mistral-7B successfully fooled larger models. For instance, Vicuna-33B saw an absolute accuracy drop of 9.0% on GSM8K and 8.4% on BBH when evaluated on the $R^2\text{ATA}$ benchmark.
  • Commercial Models vs. GPT-4: When tested against closed-source APIs, ChatGPT (GPT-3.5) exhibited an average performance drop of 6.5%. However, GPT-4 proved highly resilient, showing minimal performance degradation (only a 2.3% to 3.5% drop), indicating near-human levels of text comprehension and error tolerance.
  • Baseline Comparison: ATA significantly outperformed random typo insertion and standard instruction-focused benchmarks (like PromptBench), proving that targeted typos are far more dangerous than random noise.

Limitations and Future Work

The primary limitation acknowledged by the authors is linguistic scope: the ATA framework is currently optimized for alphabetic languages that rely on whitespaces (like English). It does not naturally translate to logographic or stroke-based writing systems like Chinese, where typos manifest as incorrect character substitutions or radical omissions.

Additionally, because of API constraints and costs, the benchmark was primarily built using open-source models as proxies; a broader evaluation across a wider variety of proprietary, closed-source architectures remains an open direction for future research.

Summary updated

BibTeX
@inproceedings{gan2024reasoning,
  author = {Esther Gan and Yiran Zhao and Liying Cheng and Yancan Mao and Anirudh Goyal and Kenji Kawaguchi and Min-Yen Kan and Michael Shieh},
  title = {{Reasoning Robustness of LLMs to Adversarial Typographical Errors}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.584},
}
Figure