Using Natural Language Explanations to Improve Robustness of In-context Learning (2024)

Abstract: Recent studies demonstrated that large language models (LLMs) can excel in many tasks via in-context learning (ICL). However, recentworks show that ICL-prompted models tend to produce inaccurate results when presented with adversarial inputs. In this work, we investigate whether augmenting ICL with natural language explanations (NLEs) improves the robustness of LLMs on adversarial datasets covering natural language inference and paraphrasing identification. We prompt LLMs with a small set of human-generated NLEs to produce further NLEs, yielding more accurate results than both a zero-shot-ICL setting and using only human-generated NLEs. Our results on five popular LLMs (GPT3.5-turbo, Llama2, Vicuna, Zephyr, and Mistral) show that our approach yields over 6% improvement over baseline approaches for eight adversarial datasets: HANS, ISCS, NaN, ST, PICD, PISP, ANLI, and PAWS. Furthermore, previous studies have demonstrated that prompt selection strategies significantly enhance ICL on in-distribution test sets. However, our findings reveal that these strategies do not match the efficacy of our approach for robustness evaluations, resulting in an accuracy drop of 8% compared to the proposed approach.

## introduction the landscape of ai has recently undergone a significant transformation with the advent of large language models (llms). these models can produce accurate predictions on unseen data after observing a small number of demonstrations. remarkably, they can achieve this based on examples provided directly in their inputs, without explicit retraining or fine-tuning -this learning paradigm is referred to as in-context learning (icl, @xcite . however, icl struggles to execute complex tasks, such as arithmetic, commonsense, and symbolic reasoning @xcite . to improve the effectiveness of icl in solving tasks requiring complex reasoning, @xcite drew inspiration from natural language explanations (nles) to introduce a method denoted as the chain-of-thought (cot) prompting. cot prompting involves prompting a model with a sequence of intermediate steps or reasoning processes to guide it towards generating more accurate answers. 2 in this work, we denote icl equipped with nles as x-icl. despite its simplicity, x-icl has advanced the performance of icl across a broad range of complex reasoning tasks @xcite . similarly to supervised learning, icl tends to be vulnerable to adversarial examples @xcite . previous research shows that improving the robustness of fine-tuned models against such adversarial datasets is possible by fine-tuning with task-relevant nles @xcite . inspired by this, we hypothesize that incorporating nles into icl could also improve the robustness of llms against adversarial examples. to this end, we evaluate the robustness of x-icl on eight adversarial datasets: hans, iscs, nan, st, picd, pisp, anli, and paws. moreover, the effectiveness of x-icl so far relies on the availability of human-written nles @xcite , which usually require domainspecific knowledge, making them hard to collect. however, the advent of llms uncovered a range of possibilities where llms can assist human annotators @xcite . motivated by this development, we investigate using three llms, namely gpt3.5-turbo, llama2, and vicuna, e v a lu a to r 1 e v a lu a to r 2 e v a lu a to r 3 e v a lu a to r 4 1 2 3 4 5 satisfaction chatgpt nles human nles to generate nles for icl. we then use human annotators to assess the quality of 200 human-written and llm-generated nles. as shown in figure 1 , most annotators (3 out of 4) prefer nles produced by chatgpt (gpt3.5-turbo) over those crafted by humans. 3 this observation further motivates us to evaluate models prompted with llm-generated nles. we then evaluate the improvement in the robustness of x-icl in three settings -in two of the settings, an llm is prompted with llm-generated nles (generated in zero-shot-icl and few-shot-icl settings, and in the last setting, the llm is prompted with human-generated nles. in the evaluation, we consider five popular llms (i.e., @xcite , zephyr @xcite , vicuna @xcite , llama2 @xcite and gpt3 .5-turbo) on eight adversarial datasets. our experimental results suggest that x-icl produces more accurate results than icl and, moreover, that nles generated by chatgpt in a few-shot-icl setting (by prompting chatgpt with human-generated nles) significantly improve over the icl baseline (+6%) for the majority of the considered datasets and llms. thus, our findings suggest that an integrated approach, combining human inputs with llms, can provide a more effective solution than utilizing either human annotators or llms in isolation. finally, we show that while prompt selection strategies (i.e., retrieving relevant training examples) can significantly improve the accuracy of icl on in-distribution test sets @xcite @xcite , they are less effective on adversarial datasets when com-2 related work learning with explanations. there has been a surge of work on explaining predictions of neural nlp systems, from highlighting decision words @xcite @xcite to generating nles @xcite @xcite . our work concentrates on the latter category, namely, the selfgeneration of nles for justifying model predictions. @xcite propose a two-stage training process to improve the prediction performance for commonsense reasoning tasks. in their work, the first stage revolves around generating nles, which are then used to inform the label prediction training process in the second stage. alternatively, one can leverage a multi-task framework to generate nles and labels simultaneously @xcite . @xcite propose advancing the reasoning abilities of smaller lms by leveraging nles generated by gpt-3 @xcite . nles have also vastly been employed beyond nlp, such as in computer vision @xcite @xcite , in the medical domain @xcite , and for selfdriving cars @xcite , with some works showing improved task performance when training with nles @xcite . however, these studies primarily concentrate on supervised fine-tuning approaches, which is different from the focus of this work, i.e., icl. ## methodology this section first outlines the workflow of x-icl. then, the focus shifts to detailing how an llm can generate an nle for a labeled instance. ## experiments we conduct a series of experiments to assess the performance of our proposed x-icl framework. 2020 ), respectively. regarding the paraphrasing identification task, we use the paws-qqp (or paws) dataset @xcite . additionally, the snli dataset (bowman et al., 2015) and qqp @xcite , which are non-adversarial, are employed for a comparative purpose. the details of these datasets are provided in appendix a. language models and prompts the evaluation of our approach is undertaken across five prominent llms: (1) mistral, (2) zephyr, (3) vicuna, (4) llama2, and (5) gpt3.5-turbo (version 0613). ## summary and outlook we introduced a simple yet effective method called fs-x-icl (chatgpt), leveraging human-written nles to generate synthetic nles by prompting chatgpt. fs-x-icl (chatgpt) significantly boosts accuracy across various adversarial datasets and five llms, compared to standard in-context learning and x-icl using human-written nles. additionally, our analysis revealed that data selection methodologies may exhibit overfitting within the in-distribution dataset, thus potentially failing to extend to unseen or adversarial datasets. in contrast, our approach employing nles has shown consistent performance in both in-distribution and adversarial contexts. our work paves the way for more robust performance and enhanced explainability capabilities of llms.