People Make Better Edits: Measuring the Efficacy of LLM -Generated Counterfactually Augmented Data for Harmful Language Detection (2023)

Abstract: NLP models are used in a variety of critical social computing tasks, such as detecting sexist, racist, or otherwise hateful content. Therefore, it is imperative that these models are robust to spurious features. Past work has attempted to tackle such spurious features using training data augmentation, including Counterfactually Augmented Data (CADs). CADs introduce minimal changes to existing training data points and flip their labels; training on them may reduce model dependency on spurious features. However, manually generating CADs can be time-consuming and expensive. Hence in this work, we assess if this task can be automated using generative NLP models. We automatically generate CADs using Polyjuice, ChatGPT, and Flan-T5, and evaluate their usefulness in improving model robustness compared to manually-generated CADs. By testing both model performance on multiple out-of-domain test sets and individual data point efficacy, our results show that while manual CADs are still the most effective, CADs generated by ChatGPT come a close second. One key reason for the lower performance of automated methods is that the changes they introduce are often insufficient to flip the original label.

## introduction for a given text with an associated label, a counterfactual example is obtained by making minimal changes to the text in order to flip its label, i.e., converting a hateful tweet into a non-hateful tweet. in this work, we compare manual cads to automated cads generated from polyjuice @xcite , chatgpt, 2 and flan-t5 (chung et al., 2022) as training data for harmful language detection models, specifically sexism and hate speech detection. with recent advances in generative nlp approaches, specifically large language models (llms), their dominance in many nlp bench-marks @xcite and their use in social computing generative tasks @xcite , we expect these generation techniques to produce high-quality cads, especially recent variants of large language models which can be accessed via prompt-based interfaces like chatgpt and flan-t5. this work aims to shed light on (i) rq1: the extent to which different automated cad generation methods are capable of generating efficient cads that boost model performance. we then use the complementary perspective of informationtheoretic formulations of dataset difficulty @xcite to obtain the 'difficulty' of manual and automated cads, i.e., how hard it is for a model family to learn them or how much useful information they entail for learnability; we then explore (ii) rq2: the properties of cads making them effective as training data -i.e., those that help improve model performance; using instancelevel difficulty scores, we study links between various properties of cads (such as the semantic and lexical distance from the original instance or their label) to surface the properties of effective cads. we find that models trained on a combination of original and manual cads outperform models trained on just originals on several ood datasets for both sexism and hate speech detection. while chatgpt cads are better training data than other automated cads, they still fare worse than manual cads. in terms of cad properties, the generation mechanism plays a strong role in the efficacy of cads -flan-t5 and polyjuice cads have high difficulty, indicating too little usable information is available from them for a model to learn. by studying various properties of cads, we discover that this is likely due to the fact that they make insufficient changes to flip the label and end up creating mislabeled cads. our results show that while mixing manual and automated cads can improve ood generalizability, we need manual vetting to ascertain the automated cads' labels instead of using a fully automated pipeline. ## related work our work sits at the intersection of automated data augmentation and understanding the quality of nlp training data. data augmentation has received increased interest in the nlp community, specifically since the advent of llms @xcite . in this work, we focus on a specific type of augmented data: counterfactually augmented data (cads, also called contrast sets by @xcite ). while some recent studies have used chatgpt for data augmentation @xcite @xcite , to the best of our knowledge, there is no prior work on using chatgpt (or other prompt-based llms) to create label-flipping cads to be used as training data. ## discussion and conclusion counterfactually augmented data, inspired by the philosophy of causality @xcite , offers an elegant approach to improving te robustness and generalizability of automated classifier. however, they are expensive to generate manually and generating them automatically has many benefits. while past work has used llms like gpt-2 for generating cads @xcite , to the best of our knowledge, there is still a lack of research on the direct comparison of manually generated cads and automated cads, especially those generated using instruction-based llms like flan-t5 or gpt-3. the specific shortcomings of automated cads are also understudies, especially for the use cases of harmful language detection. in this work, we take the first steps to show what the potentials and pitfalls of automated cads are, and to surface which of their weaknesses future work needs to pay attention to. using two complementary perspectives -1) overall performance on multiple out-of-domain datasets and 2) dataset difficulty metrics -we find that models trained on some types of counterfactually augmented data (cad) improve outof-domain generalizability of both sexism and hate speech detection models. while automated cads from chatgpt boost model performance out-ofdomain, they are typically not as effective as manual cads (rq1). we also try several baselines, including few-shot prompting of chatgpt to label the ood test sets. while chatgpt's few-shot labeling performance often surpasses the models trained on cads, we cannot rule out data contamination; chatgpt few-shot labels have high performance on all datasets predating 2022 but fall drastically for a recent sexism dataset from @xcite next, using information-theoretic measures of dataset difficulty, we further unpack issues with automated cads -flan-t5 and polyjuice cads are generated without enough change to flip the label, while for hate speech chatgpt cads are too easy-to-learn compared to manual cads, i.e., not ambiguous enough to fuel out-of-domain generalizability (rq2). our results indicate that cad generation cannot be fully automated with current llms; they require manual checking. furthermore, we find that cads with identity words are associated more strongly with the hateful class, which could worsen unintended false positive bias by misclassifying non-harmful content. nevertheless, we see some promise in combining manual and automated cads indicated by the high performance of the amcad models, which opens up intriguing possibilities for human-ai collaboration in counterfactual data augmentation; especially with promptbased interfaces where automated text generation can be controlled to tailor cads by maximizing the desirable properties we found in this work.