Knowledge Base Regulation Tracker Standards & Frameworks OSS Directory AI Incident Database Research Paper Library Case Studies Society Articles News Jobs About Charter Sign inBecome a Member

Xplique

Explainability and feature attribution

Neural network explainability toolbox with attribution methods, feature visualisation, concept-based explanations and metrics for evaluating explanations, for TensorFlow and PyTorch models.

explainabilityattributionconcepts

How it Works

Xplique is a Python-based toolkit designed to enhance the interpretability of neural network models, particularly those built with TensorFlow and PyTorch. The library consolidates state-of-the-art explainability techniques into four primary modules: Attribution Methods, Feature Visualization, Concepts, and Metrics. Each module serves a distinct purpose in dissecting how neural networks arrive at their predictions, ensuring transparency and trustworthiness in model outputs.

The Attribution Methods module implements a variety of techniques such as Saliency, Grad-CAM, Feature Perturbation (FEM), Integrated Gradients, and others. These methods generate attribution maps that highlight which input features contribute most significantly to a model’s prediction. The module supports tasks like classification, regression, object detection, and semantic segmentation across different data types, including images, time series, and tabular data.

The Feature Visualization module enables users to explore how neural networks process inputs by identifying and visualizing patterns that maximize neuron, channel, or layer activations. This is achieved through optimization techniques that generate synthetic inputs designed to activate specific components of the model. For example, users can combine objectives to maximize both a neuron’s activation and a layer’s output, providing insights into the model’s internal representations.

The Concepts module focuses on extracting human-interpretable concepts from neural networks. Techniques like Concept Activation Vectors (CAV) and Compositional Concept Activation Factors (CRAFT) allow users to define concepts using labeled datasets—positive samples containing the concept and negative samples without it. These methods quantify the presence of concepts within model layers and can localize concepts to specific regions of input data, such as images. For instance, CRAFT can decompose a model into two parts, enabling the extraction of concepts tied to specific classes (e.g., identifying visual features associated with a ‘rabbit’ class).

The Metrics module provides tools to evaluate the quality of explanations generated by attribution methods. Metrics like Deletion, Fidelity, and Complexity assess whether explanations accurately reflect the model’s decision-making process. For example, the Deletion metric measures how much a model’s prediction changes when attributed features are removed, offering a quantitative way to validate explanations.

Xplique also includes an Example-based module, which explains model predictions by retrieving relevant examples from datasets. This module supports methods like similar examples, contrastive examples (counter-factuals and semi-factuals), and prototypes. These techniques help users understand model decisions by comparing inputs to analogous or contrasting instances in the dataset, providing contextual insights into predictions.

For PyTorch models, Xplique offers a wrapper that facilitates integration with its framework. This wrapper allows users to apply attribution methods, metrics, and other functionalities to PyTorch models seamlessly, extending Xplique’s compatibility beyond TensorFlow. The wrapper ensures that PyTorch models adhere to Xplique’s API standards, maintaining consistency across frameworks.

The library requires Python 3.7 or higher and dependencies such as TensorFlow, NumPy, and other standard scientific computing libraries. Installation is straightforward via PyPI, and the toolkit is distributed under the MIT license, ensuring permissive use and modification. However, users should note that compatibility with TensorFlow 2.16 and later versions may be limited due to changes in Keras 3.X, with TensorFlow 2.15 or earlier recommended for optimal performance.

Use Cases

Xplique is tailored for researchers, data scientists, and practitioners working with complex neural network models who require transparency in their decision-making processes.

In computer vision, Xplique’s attribution methods like Grad-CAM and Integrated Gradients are commonly used to visualize which regions of an image contribute most to a model’s classification decision. Feature visualization techniques can also reveal how convolutional layers detect edges, textures, or object parts, offering deeper insights into model behavior.

For object detection and semantic segmentation, Xplique supports methods like Gradient Input and Occlusion, which help identify key pixels or regions driving detection or segmentation decisions.

In tabular data and regression tasks, Xplique’s attribution methods such as Kernel SHAP and LIME provide explanations for how individual features influence model predictions. The library’s support for regression tasks extends its utility to domains like predictive maintenance, where understanding feature contributions can optimize decision-making processes.

The Concepts module is particularly valuable in domains where human-interpretable concepts are essential, such as biology or healthcare. For example, researchers can use CRAFT to identify and localize concepts like ‘tumor presence’ or ‘cell type’ within medical images. By decomposing model predictions into understandable components, Xplique helps validate whether models are learning meaningful patterns rather than spurious correlations.

Xplique’s Example-based module is useful in scenarios where model decisions can be contextualized through dataset examples. For instance, in recommendation systems, contrastive examples can illustrate why a user might be recommended one product over another, based on similar or contrasting user behaviors. This approach enhances interpretability by grounding explanations in concrete data instances.

The Metrics module plays a crucial role in validating explanations across diverse applications. For example, in quality assurance for production models, metrics like Fidelity can ensure that attribution maps accurately reflect model behavior.

Key Features & Capabilities

Xplique’s Attribution Methods module supports a comprehensive suite of techniques, each suited to specific tasks and data types. The table below outlines the compatibility of various attribution methods with model types, data modalities, and tasks, as documented in the library’s resources. For instance, Grad-CAM is primarily used for image classification in TensorFlow models, while Integrated Gradients and Kernel SHAP are versatile, supporting both TensorFlow and PyTorch models across classification, object detection, and regression tasks.

For example, methods like Saliency and Guided Backpropagation are effective for image data in classification tasks but may not extend to object detection or semantic segmentation. In contrast, techniques such as Integrated Gradients and Occlusion are more broadly applicable, supporting images, time series, and tabular data across multiple tasks.

The Feature Visualization module enables users to generate synthetic inputs that maximize activations in specific neurons, channels, or layers. This capability is particularly useful for understanding how deep neural networks process visual information. For example, by optimizing for a neuron’s activation in the final layer of a convolutional network, users can visualize what patterns the network has learned to associate with particular classes. This technique is foundational in research aimed at reverse-engineering neural network representations.

In the Concepts module, techniques like CAV and CRAFT allow users to define and extract interpretable concepts from models. CAV involves training a linear classifier on top of a model’s intermediate layer to identify directions in feature space corresponding to human-defined concepts. CRAFT extends this idea by decomposing models into components that can be analyzed independently, enabling the extraction of concepts tied to specific classes or tasks.

The Metrics module provides quantitative tools to evaluate the quality of explanations. Metrics such as Deletion assess how much a model’s prediction changes when attributed features are removed, offering a measure of explanation fidelity. For example, the Deletion metric can reveal whether an explanation for a classification decision remains consistent when perturbed, ensuring reliability in high-stakes applications.

Xplique’s Example-based module introduces methods to explain model predictions by retrieving relevant examples from datasets. This includes similar examples, contrastive examples (counter-factuals and semi-factuals), and prototypes. Similar examples help users understand predictions by finding analogous instances in the dataset, while contrastive examples highlight differences between predicted and alternative outcomes.

The library’s support for PyTorch is facilitated through a wrapper that adapts PyTorch models to Xplique’s API. This wrapper ensures compatibility with attribution methods, metrics, and other functionalities, allowing users to apply Xplique’s tools to models trained with PyTorch. This cross-framework compatibility broadens Xplique’s utility in environments where PyTorch is the preferred deep learning framework.

This feature complements existing concept activation visualizations and importance estimation, providing a more granular understanding of model behavior. For example, users can now generate attribution maps that localize concepts like ‘sky’ or ‘road’ within an image, enhancing interpretability in tasks like scene understanding.

The library’s documentation and tutorials provide practical guidance for users, covering topics such as attribution methods for tabular data, regression, object detection, and semantic segmentation. Tutorials include hands-on examples for techniques like FORGrad, CRAFT, and Feature Visualization, with step-by-step instructions for implementation. For instance, the tutorial on CRAFT demonstrates how to decompose a model into latent and logit components, extract concepts for a specific class, and visualize the most activating input regions. These resources ensure that users can effectively integrate Xplique into their workflows, regardless of their expertise level.

Xplique’s design emphasizes modularity and extensibility, allowing users to combine methods and metrics to address specific explainability challenges. For example, a user might apply Grad-CAM to generate attribution maps for an image classification model, then use the Deletion metric to validate these maps, and finally employ CRAFT to extract and localize concepts within the model.

Sources

Contribute

Spot an error, or know a record we should add? Members can propose additions and submit corrections.