A Comparative Analysis of Counterfactual Explanation Methods for Text Classifiers

Stephen McAleese, Mark Keane · 2024

Read A Comparative Analysis of Counterfactual Explanation Methods for Text Classifiers by Stephen McAleese, Mark Keane (2024) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2411-02643.txt.

Description

Abstract Counterfactual explanations can be used to interpret and debug text classifiers by producing minimally altered text inputs that change a classifier’s output. In this work, we evaluate five methods for generating counterfactual explanations for a BERT text classifier on two datasets using three evaluation metrics.

Catalog record

CREATORStephen McAleese, Mark Keane
YEAR2024
COLLECTIONPAPERS
FORMATTXT
FILE SIZE32 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2411-02643

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

A Comparative Analysis of Counterfactual Explanation Methods for Text Classifiers Stephen McAleese, Mark Keane Abstract Counterfactual explanations can be used to interpret and debug text classifiers by producing minimally altered text inputs that change a classifier’s output. In this work, we evaluate five methods for generating counterfactual explanations for a BERT text classifier on two datasets using three evaluation metrics. The results of our experiments suggest that established white-box substitution-based methods are effective at generating valid counterfactuals that change the classifier’s output. In contrast, newer methods based on large language models (LLMs) excel at producing natural and linguistically plausible text counterfactuals but often fail to generate valid counterfactuals that alter the classifier’s output. Based on these results, we recommend developing new counterfactual explanation methods that combine the strengths of established gradient-based approaches and newer LLM-based techniques to generate high-quality, valid, and plausible text counterfactual explanations. [ [email protected] ] keywords explainable AI ,counterfactual explanations ,interpretability † † address: School of Computer Science, University College Dublin, Dublin, Ireland † † address: Insight Centre for Data Analytics, Dublin, Ireland 1 Introduction The rapid advancement of machine learning (ML) and deep learning (DL) models has led to their widespread application in real-world tasks. Due to algorithmic improvements, increased computational power, and dataset sizes, the performance of models powered by deep neural networks has surpassed traditional ML algorithms such as logistic regression and support vector machines (SVMs) on many tasks such as speech recognition, language translation, summarization, and sentiment classification LeCun et al. 2015 ; Sevilla et al. 2022 . Today, many high-performing NLP models such as BERT Devlin et al. 2019 and GPT-4 OpenAI et al. 2024 are large language models (LLMs) consisting of dozens of transformer layers and millions or billions of parameters. While these models have achieved remarkable performance across a wide range of tasks, their complexity and scale decreases their transparency and explainability. Consequently, many leading NLP models are considered to be ”black boxes”, providing outputs to users without explaining how or why they were produced Doran et al. 2017 ; Adadi and Berrada 2018 . Their lack of interpretability and explainability hinders their trustworthiness, fairness and the ability of model developers to identify potential flaws Arrieta et al. 2019 ; Doshi-Velez and Kim 2017 . For example, a black-box model may contain hidden biases or rely on spurious features to make decisions. Furthermore, the lack of transparency of these models may impede their deployment in sensitive domains such as healthcare, finance, and legal applications Adadi and Berrada 2018 . Figure 1: An example of a counterfactual explanation. The problems associated with black-box models have motivated the development of the fields of interpretability and explainable AI (XAI) which aim to develop techniques to understand the inner workings of these models and generate explanations for model outputs Gilpin et al. 2019 ; Gunning and Aha 2019 . Among the various techniques introduced for explaining ML models, research activity on counterfactual explanations has increased significantly since 2019 due to their strong support from psychological research and other benefits Keane et al. 2021 . Counterfactual explanations demonstrate how an input can be minimally altered to change a classifier’s output in order to show which parts of the input are important for determining the model’s output Wachter et al. 2017 . For example, given the sentence ”I liked the movie” classified as positive sentiment, a counterfactual input ”I hated the movie” classified as negative sentiment helps users understand the classifier’s behavior by highlighting the influence of the verb on the model’s output. Since their introduction, counterfactual explanations have been widely applied to traditional ML problems involving explicit features and tabular datasets Keane et al. 2021 . More recently, new methods have been developed to generate counterfactual explanations for deep learning models trained on image and text classification tasks Kenny and Keane 2020 . Several methods have been developed for generating counterfactual explanations for natural language processing (NLP) models such as text classifiers. However, many of the papers that introduced these methods rely on baselines from the adversarial robustness literature rather than the counterfactual explanations literature due to a lack of other methods to compare against. Furthermore, the lack of standardization of evaluation metrics and baselines in the literature increases the difficulty of evaluating different methods, making it challenging to compare their relative effectiveness or understand the strengths and weaknesses of each method. To address these issues, we conduct a comparative study of five methods for generating counterfactual explanations for a text classifier across two datasets, aiming to identify the most effective method as measured by three standardized evaluation metrics. The text classifier we aim to explain is a BERT-base model Devlin et al. 2019 fine-tuned on each dataset although any other black-box model could be used since counterfactual explanations are model-agnostic. Due to the effectiveness of large language models (LLMs) at producing plausible text outputs and handling other NLP tasks, many methods for generating counterfactual explanations for text classifiers involve LLMs. Early methods such as CLOSS (2021) Fern and Pope 2021 use LLMs to generate plausible word substitutes. Other methods such as Polyjuice (2021) Wu et al. 2021 use fine-tuned LLM models to generate counterfactuals. More recently, due to advancements in the performance of LLMs, methods such as FIZLE (2024) Bhattacharjee et al. 2024 have been developed which use only general-purpose LLMs and task-specific system prompts to generate counterfactuals without the need for additional fine-tuning or task-specific architectures. These methods leverage the instruction-following and textual understanding capabilities of recent state-of-the-art LLMs such as GPT-4 OpenAI et al. 2024 to generate high-quality counterfactuals. While these recent methods greatly simplify the process of generating text counterfactuals, it remains unclear whether they outperform older, more specialized methods and how their strengths and weaknesses differ. Given these uncertainties, our research aims to address two primary research questions: 1) Which methods for generating counterfactual explanations for text classifiers are most effective? and 2) Do newer, simpler methods that prompt general-purpose LLMs to generate counterfactuals outperform older, more specialized methods? The following list describes the contributions of this paper: 1. A review of the literature describing several past methods for generating counterfactual explanations for text classifiers. 2. A set of three standardized evaluation metrics for measuring the effectiveness of methods for generating text counterfactual explanations. 3. A comparative study of five methods for generating text counterfactual explanations across two datasets using three evaluation metrics to compare the effectiveness of each method. The rest of this paper is organized as follows: Section 2 provides a background on model explanations and counterfactual explanations, Section 3 describes a literature review of past methods for generating counterfactual explanations including detailed explanations of each of the five methods selected for our comparative study, Section 4 outlines the experimental setup for our comparative study, Section 5 presents the results of our experiments, and Section 6 summarizes our conclusions and suggests directions for future research. 2 Background 2.1 Model explanation Our research addresses the challenge of explaining the outputs from a binary classifier powered by a BERT-base neural language model Devlin et al. 2019 . Two broad approaches to explaining the predictions of deep neural networks are explaining the processing of data or explaining the representation of data

Read the complete text