Free SKILL.md scraped from GitHub. Clone the repo or copy the file directly into your Claude Code skills directory.
npx versuz@latest install hiyenwong-ai-collection-collection-skills-explainable-ai-xai-surveygit clone https://github.com/hiyenwong/ai_collection.gitcp ai_collection/SKILL.MD ~/.claude/skills/hiyenwong-ai-collection-collection-skills-explainable-ai-xai-survey/SKILL.md---
name: explainable-ai-(xai)-comprehensive-survey
description: Skill for AI agent capabilities
---
# Explainable AI (XAI) Comprehensive Survey
## Description
A comprehensive survey of Explainable AI methods from inherently interpretable models to modern approaches for black box models including LLMs. Covers XAI techniques that leverage LLM and VLM frameworks to automate or improve explainability of other ML models.
**Key Topics:**
- Inherent interpretability vs post-hoc explanations
- Black box model interpretability techniques
- LLM/VLM as interpretability methods
- High-level semantically meaningful explanations
## Tools Used
- read: Load model weights and data
- exec: Run explanation algorithms
- write: Save explanation outputs
- browser: Visualize explanations
- memory_search: Retrieve relevant XAI methods
## Instructions for Agents
### XAI Categories
1. **Inherently Interpretable Models** - Decision trees, linear models, rule-based
2. **Post-hoc Methods** - Explain trained black box models
3. **Model-Agnostic** - Work with any model (SHAP, LIME)
4. **Model-Specific** - Designed for particular architectures
### When to Use XAI
- High-stakes domains (healthcare, autonomous driving)
- Regulatory compliance requirements
- Debugging model behavior
- Building user trust
## Overview
**Source:** arXiv:2501.09967v1
**Utility:** 0.91
**Scope:** Comprehensive XAI survey including LLM interpretability
## Activation Keywords
- explainable AI
- XAI
- model interpretability
- LLM interpretability
- black box explanation
---
## XAI Method Taxonomy
### 1. Inherently Interpretable Models
| Model Type | Interpretability | Use Case |
|------------|------------------|----------|
| Linear/Logistic | Full weights visible | Simple relationships |
| Decision Trees | Rule-based paths | Categorical decisions |
| Rule Lists | Human-readable rules | Compliance domains |
| GAMs | Additive feature effects | Feature importance |
### 2. Post-hoc Explanation Methods
| Method | Type | Description |
|--------|------|-------------|
| SHAP | Model-agnostic | Shapley values for feature importance |
| LIME | Model-agnostic | Local linear approximations |
| Integrated Gradients | Gradient-based | Attribution via path integration |
| Attention Rollout | Attention-based | Attention flow in transformers |
| Grad-CAM | Vision | Gradient-weighted activations |
### 3. LLM-based XAI
```python
# Using LLM to explain other models
def llm_explanation(model_prediction, input_data):
# Get model's prediction reasoning
features = extract_important_features(model_prediction, input_data)
# Use LLM to generate human-readable explanation
prompt = f"""
The model predicted {model_prediction} based on these features:
{features}
Generate a clear, human-readable explanation.
"""
explanation = llm.generate(prompt)
return explanation
```
---
## Implementation Patterns
### SHAP (Shapley Values)
```python
import shap
def explain_with_shap(model, X):
# Create explainer
explainer = shap.Explainer(model, X)
# Calculate SHAP values
shap_values = explainer(X)
# Visualize
shap.plots.waterfall(shap_values[0])
return shap_values
```
### LIME (Local Interpretable Model-agnostic Explanations)
```python
from lime.lime_tabular import LimeTabularExplainer
def explain_with_lime(model, X_train, x_instance):
explainer = LimeTabularExplainer(
X_train.values,
feature_names=X_train.columns,
class_names=['class'],
mode='classification'
)
explanation = explainer.explain_instance(
x_instance.values,
model.predict_proba
)
return explanation.as_list()
```
### Attention Visualization (Transformers)
```python
def visualize_attention(model, text):
# Get attention weights
outputs = model(text, output_attentions=True)
attentions = outputs.attentions # (layers, heads, seq, seq)
# Rollout attention across layers
attention_rollout = compute_rollout(attentions)
# Visualize attention on tokens
visualize_attention_weights(text, attention_rollout)
```
### Integrated Gradients
```python
def integrated_gradients(model, input, baseline, steps=50):
# Interpolate from baseline to input
scaled_inputs = [baseline + (float(i)/steps) * (input - baseline)
for i in range(steps+1)]
# Compute gradients at each step
gradients = []
for scaled_input in scaled_inputs:
grad = compute_gradient(model, scaled_input)
gradients.append(grad)
# Average and multiply by (input - baseline)
avg_grad = torch.mean(torch.stack(gradients), dim=0)
return (input - baseline) * avg_grad
```
---
## LLM/VLM as Interpretability Methods
### Using LLMs to Explain
```python
class LLMExplainer:
def __init__(self, llm):
self.llm = llm
def explain_prediction(self, model, input_data, prediction):
# Extract relevant features
important_features = self.extract_features(model, input_data)
# Generate natural language explanation
prompt = f"""
A machine learning model made the following prediction:
- Prediction: {prediction}
- Important features: {important_features}
Explain this prediction in simple terms.
"""
return self.llm.generate(prompt)
def explain_feature_importance(self, feature_values, importances):
prompt = f"""
Feature importance analysis:
{list(zip(feature_values.keys(), importances))}
Summarize why these features matter.
"""
return self.llm.generate(prompt)
```
### Using VLMs for Visual Explanations
```python
class VLMExplainer:
def __init__(self, vlm):
self.vlm = vlm
def explain_image_prediction(self, image, prediction, attention_map):
# Overlay attention on image
highlighted = overlay_attention(image, attention_map)
# Generate explanation
prompt = f"""
This image was classified as {prediction}.
The highlighted regions show where the model focused.
Explain why this classification makes sense.
"""
return self.vlm.generate(prompt, highlighted)
```
---
## Application Domains
| Domain | XAI Need | Recommended Methods |
|--------|----------|---------------------|
| Healthcare | Treatment decisions | SHAP, Rule-based |
| Finance | Credit decisions | Counterfactuals |
| Autonomous Driving | Safety critical | Attention, Grad-CAM |
| Legal | Compliance | Rule-based, LLM explanations |
---
## Challenges
| Challenge | Description | Potential Solutions |
|-----------|-------------|---------------------|
| Fidelity | Does explanation match model? | Consistency checks |
| Comprehensibility | Is explanation understandable? | User studies |
| Stability | Consistent explanations for similar inputs? | Averaging methods |
| Scalability | Computational cost | Sampling approximations |
| Evaluation | How to measure explanation quality? | Human evaluation, metrics |
---
## Best Practices
1. **Match method to audience** - Technical vs non-technical users
2. **Validate explanations** - Ensure they reflect true model behavior
3. **Consider trade-offs** - Accuracy vs interpretability
4. **Use multiple methods** - Cross-validate explanations
5. **Iterate with users** - Refine based on feedback
---
## Evaluation Metrics
| Metric | Description | Formula |
|--------|-------------|---------|
| Faithfulness | Correlation with model | Remove features, check impact |
| Comprehensibility | Human understanding | User study accuracy |
| Consistency | Similar inputs → similar explanations | Pairwise comparison |
---
## Examples
### Example 1: Basic Application
**User:** I need to apply Explainable AI (XAI) Comprehensive Survey to my analysis.
**Agent:** I'll help you apply explainable-ai-xai-survey. First, let me understand your specific use case...
**Context:** Apply the methodology
### Example 2: Advanced Scenario
**User:** Complex analysis scenario
**Agent:** Based on the methodology, I'll guide you through the advanced application...
### Example 2: Advanced Application
**User:** What are the key considerations for explainable-ai-xai-survey?
**Agent:** Let me search for the latest research and best practices...
## References
- Paper: https://arxiv.org/abs/2501.09967
- DOI: https://doi.org/10.48550/arXiv.2501.09967
---
**Created:** 2026-03-28
**Source:** arXiv:2501.09967v1 - "Explainable AI: From Inherent Explainability to LLMs"