Skip to main content
QUICK REVIEW

[Paper Review] In-Context Explainers: Harnessing LLMs for Explaining Black Box Models

Nicholas Kroeger, Dan Ley|arXiv (Cornell University)|Oct 9, 2023
Explainable Artificial Intelligence (XAI)Computer Science7 citations
TL;DR

This paper introduces the first framework for using Large Language Models (LLMs) as post hoc explainers for black-box machine learning models via in-context learning (ICL). It proposes four prompting strategies—Perturbation-based, Prediction-based, Instruction-based, and Explanation-based ICL—demonstrating that LLMs achieve 72.19% accuracy in identifying the top feature responsible for predictions, matching state-of-the-art explainers while requiring no fine-tuning and operating with only a few few-shot examples.

ABSTRACT

Recent advancements in Large Language Models (LLMs) have demonstrated exceptional capabilities in complex tasks like machine translation, commonsense reasoning, and language understanding. One of the primary reasons for the adaptability of LLMs in such diverse tasks is their in-context learning (ICL) capability, which allows them to perform well on new tasks by simply using a few task samples in the prompt. Despite their effectiveness in enhancing the performance of LLMs on diverse language and tabular tasks, these methods have not been thoroughly explored for their potential to generate post hoc explanations. In this work, we carry out one of the first explorations to analyze the effectiveness of LLMs in explaining other complex predictive models using ICL. To this end, we propose a novel framework, In-Context Explainers, comprising of three novel approaches that exploit the ICL capabilities of LLMs to explain the predictions made by other predictive models. We conduct extensive analysis with these approaches on real-world tabular and text datasets and demonstrate that LLMs are capable of explaining other predictive models similar to state-of-the-art post hoc explainers, opening up promising avenues for future research into LLM-based post hoc explanations of complex predictive models.

Motivation & Objective

  • To investigate whether LLMs can serve as reliable post hoc explainers for black-box models without requiring model fine-tuning or white-box access.
  • To develop and evaluate a novel framework leveraging in-context learning (ICL) to generate faithful, human-interpretable explanations for model predictions.
  • To compare the faithfulness and accuracy of LLM-generated explanations against state-of-the-art post hoc explanation methods like LIME and SHAP.
  • To analyze the impact of prompting design, ICL sample count, and LLM architecture (e.g., GPT-3.5 vs. GPT-4) on explanation quality.
  • To establish a benchmark for evaluating LLM-based explanation frameworks in explainable AI (XAI).

Proposed method

  • Proposes four distinct in-context learning (ICL) prompting strategies: Perturbation-based ICL, Prediction-based ICL, Instruction-based ICL, and Explanation-based ICL, each varying in the information provided about the local neighborhood and model behavior.
  • Uses real-world benchmark datasets and two black-box models (e.g., Logistic Regression) to evaluate LLM-generated explanations.
  • Employs a suite of faithfulness metrics—Faithfulness (FA), Representation Accuracy (RA), and Prediction Gradient Importance (PGI)—to quantitatively assess explanation quality.
  • Leverages GPT-3.5 and GPT-4 as the LLM backbone, comparing their performance across prompting strategies and hyperparameter settings.
  • Applies ablation studies on ICL sample count, perturbation format, and temperature hyperparameters to assess sensitivity and optimal configuration.
  • Introduces utility functions and parsing tools to standardize LLM-based explanation extraction and evaluation within the framework.
Figure 1: Overview of our framework. Given a dataset and model to explain, we provide 1) different prompting strategies to generate explanations using LLMs, 2) functions to parse LLM-based explanations, 3) utility functions to support new LLMs, and 4) diverse performance metrics to evaluate the fait
Figure 1: Overview of our framework. Given a dataset and model to explain, we provide 1) different prompting strategies to generate explanations using LLMs, 2) functions to parse LLM-based explanations, 3) utility functions to support new LLMs, and 4) diverse performance metrics to evaluate the fait

Experimental results

Research questions

  • RQ1Can LLMs effectively generate post hoc explanations for black-box models using in-context learning without fine-tuning?
  • RQ2How does the performance of LLM-generated explanations compare to state-of-the-art post hoc explainers like LIME and gradient-based methods?
  • RQ3What is the impact of varying the number of in-context examples on the faithfulness of LLM-generated explanations?
  • RQ4How do different prompting strategies (e.g., instruction-based vs. perturbation-based) affect explanation faithfulness and accuracy?
  • RQ5Does the choice of LLM architecture (e.g., GPT-3.5 vs. GPT-4) significantly influence the quality of generated explanations?

Key findings

  • LLMs achieve an average of 72.19% accuracy in identifying the most important feature (top-k=1) across four benchmark datasets and two black-box models, demonstrating strong performance as post hoc explainers.
  • Explanation-based ICL, which provides few-shot examples of input-output-explanation triples, enables LLMs to mimic the behavior of six state-of-the-art explainers using only four in-context examples.
  • GPT-4 outperforms GPT-3.5 across all metrics, achieving 4.53% higher Faithfulness (FA) and 48.01% higher Representation Accuracy (RA) on the Adult dataset, attributed to its superior reasoning capabilities.
  • Increasing the number of in-context examples beyond a small set (e.g., to 64) reduces explanation faithfulness, indicating that longer prompts impair LLMs' ability to retrieve relevant information.
  • The faithfulness of LLM-generated explanations is sensitive to prompting design: using the difference between perturbed and original samples as input improves performance, while high temperature values show minimal impact on output quality.
  • Instruction-based ICL outperforms perturbation- and prediction-based ICL in terms of Representation Accuracy (RA), suggesting that clear, structured instructions enhance explanation faithfulness.
Figure 2: PGU and PGI scores of explanations generated using post hoc methods and LLMs (Instruction-based, Prediction-based, and Perturbation-based ICL prompting strategies) for an ANN model. On average, across four datasets, we find that LLM-based explanations perform on par with gradient-based and
Figure 2: PGU and PGI scores of explanations generated using post hoc methods and LLMs (Instruction-based, Prediction-based, and Perturbation-based ICL prompting strategies) for an ANN model. On average, across four datasets, we find that LLM-based explanations perform on par with gradient-based and

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.