Abstract
Explanations of machine learning (ML) model predictions generated by Explainable AI (XAI) techniques such as SHAP are essential for people using ML outputs for decision-making. We explore the potential of Large Language Models (LLMs) to transform these explanations into human-readable, narrative formats that align with natural communication. We address two key research questions: (1) Can LLMs reliably transform traditional explanations into high-quality narratives? and (2) How can we effectively evaluate the quality of narrative explanations? To answer these questions, we introduce Explingo, which consists of two LLM-based subsystems, a Narrator and Grader. The Narrator takes in ML explanations and transforms them into natural-language descriptions. The Grader scores these narratives on a set of metrics including accuracy, completeness, fluency, and conciseness. Our experiments demonstrate that LLMs can generate high-quality narratives that achieve high scores across all metrics, particularly when guided by a small number of human-labeled and bootstrapped examples. The findings from this work have been integrated into an open-source tool that makes narrative explanations available for further applications.
Introduction
While Explainable AI (XAI) has made significant progress with techniques like SHAP (SHapley Additive exPlanations), the outputs are often technical, consisting of raw numerical contributions or complex visualizations. For non-expert stakeholders—such as doctors or loan officers—these formats lack the intuitive clarity of natural language. Explingo addresses this gap by leveraging Large Language Models (LLMs) to bridge the divide between technical feature importance and human stories.
The challenge in this transformation is twofold: ensuring technical reliability (avoiding hallucinations) and establishing a scalable method for quality evaluation. Explingo solves these by pairing a generation engine with an automated grading agent.
The Explingo Framework
Explingo is built using the DSPy framework and consists of two primary components: the Narrator and the Grader.
The Narrator
The Narrator is responsible for the core task of translation. It receives the ML prediction, the technical SHAP values, and a context string defining the model's purpose. To ensure the output matches a specific linguistic style (e.g., casual vs. precise), the Narrator utilizes few-shot prompting with "exemplars"—sample narratives that serve as style guides.
The Grader
To automate quality control, Explingo introduces an independent LLM-based Grader. This agent evaluates narratives across four key metrics: Accuracy, Completeness, Fluency, and Conciseness. A critical innovation in the Grader's design is the use of Chain-of-Thought (CoT) prompting. By requiring the Grader to first list all features present in the narrative before assigning a score, the system significantly improves its ability to detect factual errors or omissions.
Methodology and Optimization
The system was evaluated across four diverse domains: Ames Housing (regression), Student Performance (classification), Mushroom Toxicity (safety-critical classification), and PDF Malware detection.
To optimize performance, Explingo employs "Bootstrapped Few-Shot" learning. Starting with a minimal set of human-written examples, the system uses the Grader to identify or generate superior examples to include in future prompts. This self-improving loop ensures that the Narrator is guided by the most technically accurate and stylistically appropriate exemplars.
Key Insights
- The Power of Exemplars: LLMs require specific examples to avoid generic outputs. With 3–5 exemplars, the model can mimic complex linguistic styles with high fidelity.
- Reliability of Automated Grading: With CoT prompting, the automated Grader achieved a 96% agreement rate with human labels for accuracy and completeness, suggesting it can serve as a reliable guardrail in production environments.
- Contextual Necessity: LLMs struggle with relative terms (e.g., "large") unless provided with global dataset statistics, such as means or medians, to ground the numerical values.
- Bootstrapping Efficacy: Examples filtered or generated by the Grader often outperformed purely human-written ones because the system strictly enforces technical accuracy during the selection process.
Conclusion and Future Work
Explingo demonstrates that LLMs can reliably transform technical XAI data into accessible narratives. While the system excels at style mimicry and accuracy, future work will focus on integrating broader statistical context to improve comparative logic and refining performance on smaller, edge-deployed models. The Explingo framework is now available as part of pyreal, an open-source library for machine learning refactoring.
Summary updated