Introduction
Explainable AI (XAI) aims to demystify the "black box" of machine learning, yet the field faces a fundamental validation crisis. While Feature Attribution (FA) methods like SHAP and Integrated Gradients are widely used to identify influential inputs, they often yield conflicting results for the same prediction. This "disagreement problem" stems from a lack of objective ground truth: without knowing how a model actually processes information, it is impossible to determine which explanation is correct. XAI-Units addresses this by introducing a rigorous benchmarking framework inspired by software unit testing.
The Disagreement Problem in Feature Attribution
Practitioners rely on FA methods to ensure models are making decisions for the right reasons. However, when two methods provide different importance scores, the source of the error is ambiguous. Is the explanation method failing, or is the model itself behaving unexpectedly due to poor optimization or noise? Existing benchmarks often use real-world data where the true logic is unknown, or synthetic data to train models that may still contain hidden artifacts.
Methodology: Handcrafted Models as Unit Tests
XAI-Units sidesteps the ambiguity of trained models by utilizing procedurally generated, handcrafted models. Instead of training a neural network, the framework manually defines weights and architectures to replicate specific "atomic" behaviors.
This approach provides several key advantages:
- Deterministic Ground Truth: Because the model’s internal logic is mathematically predefined, the "correct" attribution score is known with absolute certainty.
- Isolated Testing: Each "unit" in the benchmark isolates a specific challenge, such as discontinuous outputs (Shattered Gradients) or features that cancel each other out (Conflicting Features).
- Verification of Implementations: The framework can detect bugs in XAI libraries. For instance, it revealed that the Captum library's implementation of DeepLIFT handled Softmax outputs differently than intended, a discrepancy only visible against a known perfect score.
Multi-Modal Benchmarking
The framework supports a diverse range of data modalities, each designed to test specific aspects of interpretability:
- Tabular Data: Includes seven generators covering scenarios like Pertinent Negatives and complex Boolean Formulae.
- Image Data: Uses synthetic generators that overlay objects onto various textures to test whether FA methods can distinguish foreground objects from background noise.
- Text Data: Employs a "Trigger Injection" dataset with a fine-tuned Llama-3 model, where a specific trigger word ("Bumfuzzle") is hard-coded to produce a specific output token, creating a clear expectation for attribution.
Key Findings
The systematic evaluation of FA methods through XAI-Units yielded several critical insights:
Gradient Blindness
Gradient-based methods, such as Integrated Gradients, struggle significantly with "conflicting features." When two features cancel each other's influence, the gradients may drop to zero, leading the method to report zero importance for both—even when they are central to the model's logic. In contrast, perturbation-based methods like ShapleyValueSampling proved more robust in these non-linear scenarios, albeit at a higher computational cost.
Architectural Bias
In image tasks, Vision Transformers (ViTs) were found to be more prone than CNNs to focus on background pixels. This suggests that the global attention mechanism of ViTs may increase susceptibility to spurious correlations, a finding that has significant implications for deploying these models in sensitive domains.
LLM Interpretability
For Large Language Models, FeatureAblation and ShapleyValueSampling were the most reliable methods. Integrated Gradients performed poorly, likely due to the discrete nature of text tokens, which lacks the continuous "intermediate" states that gradient-based methods typically require.
Conclusion
XAI-Units provides a necessary foundation for the objective evaluation of interpretability methods. By moving from "best-guess" explanations on trained models to "unit tests" on handcrafted ones, the framework allows researchers to diagnose specific failure modes in XAI algorithms. While synthetic tests do not replace real-world validation, they offer a critical debugging step to ensure that our explanations are built on a mathematically sound foundation.
Summary updated