AI
What Is Explainable AI (XAI)? A Plain Guide
Explainable AI (XAI) in plain language: why it matters, how SHAP, LIME and other methods work, real examples, explaining LLMs, and the laws behind it.
Explainable AI (XAI) is the set of methods that make an AI system's decisions understandable to people: which inputs drove a prediction, how much each one mattered, and why the model chose one answer over another. It matters most when AI affects people's lives, such as loans, hiring, medical decisions and fraud flags, because users, regulators and the people affected need to understand and challenge those decisions. The most widely used techniques are SHAP and LIME for explaining individual predictions, plus simpler, inherently interpretable models when the stakes are high.
This guide explains what explainable AI is, why it matters, how the main methods work with examples, SHAP vs LIME, the special problem of explaining large language models, and the laws that now require explanations.
What Is Explainable AI?
Many modern AI models are "black boxes": they're accurate, but even their developers can't easily say why a particular input produced a particular output. A neural network with millions or billions of parameters doesn't come with a list of reasons.
Explainable AI tries to open that box in two ways:
- Interpretable models: use models whose logic people can read directly, such as small decision trees, linear models or rule lists.
- Post-hoc explanations: keep the complex model, and use extra techniques to explain its behaviour after the fact.
XAI explanations can be global (how the model works overall: which features matter most across all decisions) or local (why the model made this specific decision for this specific person).
You'll also see the term interpretable machine learning. It's often used interchangeably with XAI, though some researchers reserve "interpretable" for models that are understandable by design and "explainable" for explanations added to black-box models.
Why Explainable AI Matters
- Trust. Doctors, loan officers and analysts are more willing to act on a model's output when they can see its reasoning.
- Fairness. Explanations reveal when a model relies on sensitive attributes or proxies for them, such as postcode standing in for ethnicity. Our guide to AI bias covers how that happens.
- Debugging. Explanations expose models that learned shortcuts, like an image classifier that recognizes snow instead of wolves.
- Accountability. When a decision is challenged, organizations need to show how it was made.
- Regulation. Credit, insurance, employment and public-sector decisions increasingly come with legal explanation requirements.
- Learning. Scientists use explanations to discover which factors matter in their data.
How Explainable AI Works: The Main Methods
| Method | Type | What it tells you | Typical use |
|---|---|---|---|
| Interpretable models (linear models, small trees, rule lists, GAMs) | By design | The full logic of the model | High-stakes tabular decisions |
| Feature importance | Global, post-hoc | Which inputs matter most overall | Understanding and auditing a model |
| SHAP | Local and global, post-hoc | Each feature's contribution to a specific prediction | Credit, risk, churn, medical models |
| LIME | Local, post-hoc | Which features drove one prediction, via a simple local model | Quick explanations of single predictions |
| Partial dependence and ICE plots | Global, post-hoc | How the prediction changes as one feature changes | Checking sensible relationships |
| Counterfactual explanations | Local, post-hoc | The smallest change that would flip the decision | Telling people what they could change |
| Saliency maps (e.g. Grad-CAM) | Local, post-hoc | Which parts of an image the model focused on | Medical imaging, vision models |
| Attention and attribution for text | Local, post-hoc | Which words influenced the output | NLP models |
| Mechanistic interpretability | Research | Which internal features and circuits produce behaviour | Understanding large neural networks |
Interpretable by design
For many decisions on structured data, such as credit scores or hospital readmission risk, simple models like logistic regression, small decision trees or generalized additive models (GAMs) perform close to complex ones. Their logic can be read directly: "each late payment adds 12 points of risk". Many researchers argue that for high-stakes decisions, you should use an interpretable model whenever its accuracy is close enough, instead of explaining a black box afterwards.
Counterfactual explanations
A counterfactual explanation answers "what would have to change for a different result?" For example: "Your loan would have been approved if your income were $4,000 higher or your credit card balance $2,500 lower." People find these intuitive and actionable, which is why they're popular for customer-facing explanations.
SHAP vs LIME
SHAP vs LIME is the most common comparison in practical XAI, because both explain individual predictions of any model.
SHAP (SHapley Additive exPlanations), introduced by Lundberg and Lee in 2017, uses Shapley values from game theory. It treats each feature as a "player" in a game whose payout is the prediction, and fairly divides the prediction among the features based on their average contribution across all possible combinations.
LIME (Local Interpretable Model-agnostic Explanations), introduced by Ribeiro, Singh and Guestrin in 2016, explains one prediction by creating many slightly changed versions of that input, seeing how the model's output changes, and fitting a simple, interpretable model to those nearby examples.
| SHAP | LIME | |
|---|---|---|
| Theory | Shapley values from cooperative game theory | Local surrogate model around one example |
| Explanations | Local, and can be aggregated into global views | Local only |
| Consistency | Contributions add up exactly to the prediction | Can vary between runs |
| Speed | Fast for tree models with TreeSHAP; slow for some other models | Usually fast |
| Weaknesses | Can be expensive; assumes features can be varied independently | Results depend on how samples are generated; less stable |
| Good for | Audits, regulated decisions, global understanding | Quick checks, prototypes, text and image examples |
In practice, SHAP has become the default for tabular models in industry, especially tree-based models, while LIME remains handy for quick, intuitive explanations. Both share important limits: they explain what the model does, not what's true in the world, and they can mislead when features are strongly correlated.
Explainable AI Examples
Here are explainable AI examples from real domains:
- Lending: a SHAP explanation shows that a declined application was driven mainly by a high debt-to-income ratio and recent missed payments, and the lender uses those as the stated reasons.
- Healthcare: a saliency map highlights the region of an X-ray that drove a model's pneumonia prediction, so a radiologist can check that the model looked at the lungs and not at a hospital label in the corner.
- Fraud detection: an analyst sees that a transaction was flagged because of an unusual device, location and amount combined, and can review it faster.
- Hiring: an audit of feature importance reveals a model leaning on gaps in employment history, prompting a fairness review.
- Customer churn: global SHAP values show that support ticket volume and declining usage predict churn far more than price, which changes the retention strategy.
- Manufacturing: a model predicting defects shows that temperature in one stage of the line matters most, pointing engineers to the root cause.
A worked example
Imagine a credit model that estimates a 32% chance of default for an applicant, against an average of 20% across all applicants. A SHAP explanation might break down the 12-point difference like this:
| Feature | Value for this applicant | Contribution to risk |
|---|---|---|
| Debt-to-income ratio | 48% | +7 points |
| Missed payments (last 12 months) | 2 | +6 points |
| Years at current job | 1 | +2 points |
| Savings balance | High | −3 points |
| Total | +12 points (20% → 32%) |
Each contribution shows how much a feature pushed the prediction up or down from the average. The lender can now tell the applicant the main reasons, and a reviewer can check that nothing inappropriate drove the decision.
Explaining Large Language Models
Large language models are much harder to explain than a credit model. They have billions of parameters, work on text rather than a few labelled features, and produce open-ended answers.
Current approaches include:
- Citations and grounding: in retrieval-augmented systems, showing which sources an answer came from is the most practical form of explanation.
- Chain-of-thought reasoning: reasoning models show their steps, which helps, but research from Anthropic and others has found that the stated reasoning doesn't always reflect what actually drove the answer, so it isn't a reliable explanation on its own.
- Attribution methods: techniques that estimate which parts of the input most influenced the output.
- Mechanistic interpretability: research that identifies internal "features" and circuits inside models, such as Anthropic's work mapping millions of concepts inside its Claude models and tracing how they combine to produce answers. It's promising but still far from fully explaining a model's behaviour.
For now, explainability for LLM applications relies mostly on system design: grounding answers in sources, logging inputs and outputs, limiting what the model can decide on its own, and keeping humans responsible for high-stakes decisions.
Laws That Require Explanations
- EU AI Act: high-risk AI systems must be transparent enough for users to interpret their output and use it appropriately, and people affected by decisions based on certain high-risk systems have a right to a clear explanation of the AI's role in the decision.
- GDPR: for significant decisions made solely by automated means, people are entitled to meaningful information about the logic involved, and to human review in many cases.
- US credit law: under the Equal Credit Opportunity Act, lenders must give specific reasons when they deny credit, and the Consumer Financial Protection Bureau has said this applies even when they use complex algorithms.
- Sector rules: insurance, healthcare and employment regulators in many countries set their own requirements.
If your AI system makes or supports decisions about people, explanations aren't optional. Our guide to writing an AI policy for companies covers how to build these requirements into your governance.
Limits of Explainable AI
- Explanations can be wrong or misleading, especially with correlated features or when the explanation method's assumptions don't hold.
- Plausible isn't faithful: an explanation that sounds sensible may not reflect what the model really did.
- Explanations can be gamed: research has shown models can be built to look fair under some explanation methods while behaving unfairly.
- Too much detail confuses: a 40-feature breakdown helps a data scientist, not a loan applicant.
- Accuracy trade-offs: sometimes the most interpretable model is less accurate, though often less than people assume.
How to Make Your AI More Explainable
- Start with the audience. Regulators, data scientists, frontline staff and customers need different explanations.
- Try an interpretable model first for high-stakes tabular decisions, and only move to a black box if it's clearly better.
- Use SHAP for tabular models to produce both global summaries and per-decision reasons.
- Test explanations with users to see whether they understand and trust them appropriately.
- Document the model: data sources, intended use, limits and known failure cases.
- Monitor over time, because explanations change as data drifts.
- Keep humans accountable for decisions the AI supports.
Explainable AI vs Interpretable AI vs Responsible AI
These terms overlap but aren't identical:
- Interpretable AI usually means models whose inner workings people can understand directly, such as a small decision tree or a linear model with a handful of features.
- Explainable AI is broader: it includes interpretable models and techniques like SHAP and LIME that explain black-box models after the fact.
- Responsible AI is broader still: a set of practices covering fairness, privacy, safety, accountability and transparency. Explainability is one part of it.
In practice, a responsible AI programme uses explainability as a tool: to check fairness, to support human oversight and to give people affected by decisions a meaningful account of them.
FAQ
What is explainable AI in simple terms?
Explainable AI is AI whose decisions people can understand: it shows which inputs mattered and why the system reached a result, so users can trust, check and challenge it.
What does XAI stand for?
XAI stands for explainable artificial intelligence: methods and practices that make AI systems' behaviour and decisions understandable to humans.
What is the difference between SHAP and LIME?
Both explain individual predictions of any model. SHAP uses Shapley values from game theory and gives consistent contributions that add up to the prediction. LIME fits a simple model to slightly changed versions of one input; it's often faster but less stable.
Is ChatGPT explainable?
Only partly. Large language models are hard to explain internally. Citations to sources, visible reasoning and logging help, but research shows a model's stated reasoning doesn't always match what drove its answer, and full mechanistic explanations remain a research goal.
Why is explainable AI important?
It helps people trust AI appropriately, detect bias and errors, meet legal requirements for decisions about loans, jobs and healthcare, and hold organizations accountable for AI-supported decisions.