L ogic A ttack: Adversarial Attacks for Evaluating Logical Consistency of Natural Language Inference (2023)

Abstract: Recently Large Language Models (LLMs) such as GPT-3, ChatGPT, and FLAN have led to impressive progress in Natural Language Inference (NLI) tasks. However, these models may rely on simple heuristics or artifacts in the evaluation data to achieve their high performance, which suggests that they still suffer from logical inconsistency. To assess the logical consistency of these models, we propose a LogicAttack, a method to attack NLI models using diverse logical forms of premise and hypothesis, providing a more robust evaluation of their performance. Our approach leverages a range of inference rules from propositional logic, such as Modus Tollens and Bidirectional Dilemma, to generate effective adversarial attacks and identify common vulnerabilities across multiple NLI models. We achieve an average ~53% Attack Success Rate (ASR) across multiple logic-based attacks. Moreover, we demonstrate that incorporating generated attack samples into training enhances the logical reasoning ability of the target model and decreases its vulnerability to logic-based attacks. Data and source code are available at https://github.com/msantoshmadhav/LogicAttack.

## introduction recently, llms have demonstrated impressive performance on natural language inference (nli) tasks @xcite . prior to the introduction of prompt paradigm, the top-performing nli systems relied heavily on pre-training, followed by fine-tuning on labeled task-specific data @xcite . however, with the emergence of prompt-based llms, these models have achieved good performance (∼ 90%) on nli tasks with minimal training data (i.e., few-shot learning) @xcite . these systems have demonstrated robustness to variations on syntax and lexical level, and the ability to generalize beyond training data @xcite . however, a crucial question remains: do these models generate a logical output on nli, or do they rely on simple heuristics and learn shortcuts to generate their results? hence, we believe that logical reasoning is a critical component of nli systems and should be subject to evaluation. here, we aim to address an important question: "are widely used nli models exhibit logical consistency?" although attempts have been made to create adversarial attacks for nli @xcite , and also to evaluate the logical consistency of llms across a range of tasks @xcite , they do not consider logic-based attack generation foot_1 . to bridge this gap, we propose logicattack, a method to create logicbased adversarial attacks that utilize a variety of inference rules from propositional logic (pl). here, we utilize pl since pre-training data (usually data from the web or books) lacks sufficient explicit relations @xcite between propositions in different inference rules, making it essential to evaluate reasoning ability of models on such logic-based relationships. specifically, we employ six inference rules to generate attacks from pl. in this work, we evaluate range models, including both fine-tuned models on nli such as roberta @xcite , and bart @xcite ; and prompt-based models such as gpt-4, gpt-3 @xcite , @xcite , using logicattack. experimental results show that the logic- ## logicattack this section provides a detailed description of task formulation, our attack strategies, and algorithm. ## conclusions we introduce logicattack, a novel method for generating logic-based attacks to assess the robustness of nli models. we evaluate a range of models on nli, considering single-task, multi-task, and prompting. experimental results demonstrate that these models are vulnerable to logic-based adversarial attacks, as evidenced by their higher asr. additionally, we investigate the impact of finetuning models with attack samples and observe a significant improvement in their logical reasoning capabilities, leading to a substantial decrease in asr. overall, our findings suggest that logicattack provides a valuable framework for conducting logically consistent evaluations of models.