TLDR: This research paper explores how using ‘counterfactuals’ can improve Large Language Models’ (LLMs) ability to explain their textual classification decisions. Counterfactuals are minimally modified versions of an input text that flip the LLM’s classification. The study introduces a ‘decision-changing rate’ metric to quantify the importance of identified key words. It finds that counterfactual-based methods, particularly the Counterfactual-Parallel approach, consistently enhance LLM explainability, especially for medium and long texts, by helping them pinpoint the most influential words in their decisions.
Large Language Models (LLMs) have become incredibly powerful tools across many fields, especially in tasks like textual classification. While their ability to categorize text is impressive, understanding *why* an LLM makes a particular decision remains a significant challenge. This is crucial for businesses that use these models as black boxes, meaning they don’t have access to the internal workings, and where every LLM call can be expensive.
A recent research paper, “Does Using Counterfactual Help LLMs Explain Textual Importance in Classification?”, explores how incorporating ‘counterfactuals’ into LLM reasoning can improve their ability to identify the most important words contributing to a classification decision. The authors, Nelvin Tan, James Asikin Cheung, Yu-Ching Shih, Dong Yang, and Amol Salunkhe from American Express, introduce a novel framework and metric to quantify this importance.
What are Counterfactuals?
At its core, a counterfactual explanation involves finding a minimally altered version of an input text that would change the LLM’s classification outcome. For example, if an LLM classifies “This item is neither affordable, nor of good quality” as ‘negative’, a counterfactual might be “This item is both affordable, and of good quality”, which would then be classified as ‘positive’. The goal is to identify the smallest changes that flip the decision, thereby highlighting the most influential words in the original text.
The Challenge of Explainability
Traditional explainability techniques like SHAP and LIME are often too costly for LLMs, requiring hundreds or thousands of calls. Directly prompting an LLM to explain itself can be simpler but doesn’t always reflect the model’s true internal reasoning. This research is motivated by the need for cost-effective and reliable methods to explain black-box LLMs like GPT-4o, focusing on identifying key words that drive classification decisions.
New Approaches to Explanation
The paper introduces three main approaches to help LLMs identify important words:
- Direct Prompting (DP): The LLM is simply asked to classify the text and list the top-k most important words.
- Counterfactual-Parallel (CFP): The LLM first generates a counterfactual (a minimally modified text that changes the classification). If a valid counterfactual is found, both the original and counterfactual texts are fed to the LLM in parallel, asking it to identify the top-k words from the original text that led to its initial decision.
- Counterfactual-Sequential (CFS): This approach starts with Direct Prompting to get initial top-k words. Then, a counterfactual is generated. If successful, the LLM is asked to refine its initial selection of top-k words by considering both the original and counterfactual texts.
Measuring Importance: The Decision-Changing Rate
To evaluate how well these approaches work, the researchers developed a new metric called the “decision-changing rate” (DCR). This metric works by taking the top-k important words identified by an LLM, masking them in the original text, and then asking the LLM to replace these masked words with new ones that would flip the original classification. If the LLM successfully flips the classification with these replacements, the score is 1; otherwise, it’s 0. The DCR is the average of these scores, indicating how critical the identified words are to the LLM’s decision.
Experimental Findings
The study used various textual binary classification datasets (Amazon for short texts, SST2 for medium, and IMDB for long) and two LLMs (LLaMA3-70B as a weaker model and GPT-4o as a stronger one). Key observations include:
- As expected, increasing the number of identified words (k) generally increases the DCR, as there are more opportunities to change the sentiment.
- Weaker models (LLaMA3-70B) tend to have higher DCRs, suggesting their decisions are more easily influenced.
- The effectiveness of the identified words (DCR) decreases as the proportion of k to the total word length of the input string gets smaller, especially in very long texts like IMDB reviews.
- For short texts (Amazon), Counterfactual-Parallel (CFP) performed best or matched Direct Prompting (DP).
- For medium (SST2) and long (IMDB) texts, both CFP and Counterfactual-Sequential (CFS) consistently outperformed Direct Prompting (DP). CFP showed slightly more consistent superior performance overall.
Also Read:
- Understanding Smart Environments: When “What If” Explanations Help Most
- Decoding AI’s Thought Process: The Role of Internal States in Reasoning Models
Conclusion and Future Directions
The research concludes that incorporating counterfactuals significantly helps LLMs explain the importance of input words in textual classification. The Counterfactual-Parallel (CFP) approach is recommended for its consistent performance. This work introduces a valuable new metric, the decision-changing rate, for evaluating LLM explainability. Future work could extend this framework to multi-class classification problems.
While the study provides strong evidence for the utility of counterfactuals, the authors acknowledge limitations, such as not exhaustively evaluating a wide range of LLMs and minor noise in DCR calculations due to LLMs occasionally altering unmasked words.


