xai-efficiency-benchmark
A toolkit to measure and compare the runtime, memory, and energy overhead of popular explainable AI (XAI) methods on various models and datasets.
Science Score: 49.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 1 DOI reference(s) in README -
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.2%) to scientific vocabulary
Repository
A toolkit to measure and compare the runtime, memory, and energy overhead of popular explainable AI (XAI) methods on various models and datasets.
Basic Info
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
XAI Efficiency Benchmark
A toolkit to measure and compare the runtime, memory, and energy overhead of popular explainable AI (XAI) methods on various models and datasets.
Motivation
Explainable AI is crucial for trust and transparency in model decisions. However, many explanation techniques introduce significant computational overhead. For example, perturbation-based methods may require hundreds or thousands of forward passes to generate a single explanation (OpenVINO Explainable AI Toolkit User Guide OpenVINO XAI 1.1.0 documentation), and model-agnostic methods like SHAP can be prohibitively slow on large models (Explainable artificial intelligence (XAI): from inherent explainability to large language models). This efficiency gap means some XAI methods are impractical for real-time or resource-constrained deployment. Balancing interpretability with computational efficiency is a known trade-off (Do All AI Systems Need to Be Explainable?). This toolkit benchmarks a variety of XAI methods across models and datasets, quantifying their runtime, memory, and energy costs.
Prerequisites
- Python: 3.9 (added to
PATH) - Git: to clone this repository
Setup Instructions (Windows 10/11)
Open PowerShell as Administrator.
Navigate to your project folder:
powershell cd C:\path\to\your_projectCreate a Python 3.9 virtual environment:
powershell python3.9 -m venv env39Activate the environment:
powershell .\env39\Scripts\activateOpen your code editor (e.g., VSCode, Cursor) and restart the integrated terminal if needed.
Clone this repository and
cdinto it:powershell git clone https://github.com/Alimzade/xai-efficiency-benchmark.git cd xai-efficiency-benchmarkInstall dependencies in the terminal
pip install captum memory_profiler opencv-python requests tensorflow ipykernel pandas scikit-image scikit-learn seaborn pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
Dataset Download
No need if using images from URLs
For ImageNet:
1. Obtain a Hugging Face access token at https://huggingface.co/settings/tokens
2. Insert the token into datasets\imagenet_download.py as instructed in that file.
Then download all datasets with (may take some time):
powershell
python datasets\download.py
Running Benchmarks
benchmark.ipynb(recommended): select method, model, dataset, hardware, and run full suite.local_benchmark.ipynb: run one configuration per cell.LIME_benchmark.ipynb: tune perturbation settings (e.g., sample count).extended_benchmark.ipynb: includes global XAI methods and aggregated views.
Results (JSON, CSV, plots) will be saved in experiment_results/.
Extending the Framework
- Add XAI methods: place a new Python file in
xai_methods/following existing templates. - Add models: update scripts in
models/folder to include loading logic for your model (architecture and weights). - Add datasets: update loader scripts in
datasets/(data_loader.py&dataset_loader.py) and updatedownload.pyif needed.
Utilities
The utils/ folder contains helper modules:
utils/benchmark_utils.py: Add your hardware information here.
Output and Results
- Raw results: After running benchmarks, raw output (e.g., runtime logs, memory usage) is saved in
experiment_results/. All experiment results are saved in the same place; therefore, clean folders (usingclean_folders.ipynb). - Figures: Run
evaluation.ipynbto generate figures and tables if needed. Thefigures/folder contains generated plots (PNG/HTML) comparing methods by runtime, memory, and energy. These visuals help quickly see the efficiency differences.
By inspecting these results, researchers can identify which XAI methods are most practical under resource constraints and how to optimize their use.
Citation
If you use this tool in your work, please cite as below:
bibtex
@software{alimzade2025xai,
author = {Anar Alimzade},
title = {Efficiency Benchmark for XAI},
year = {2025},
month = {May},
doi = {10.5281/zenodo.15321812},
version = {1.0.0}
}
Owner
- Login: Alimzade
- Kind: user
- Repositories: 1
- Profile: https://github.com/Alimzade
GitHub Events
Total
- Release event: 1
- Watch event: 2
- Push event: 13
- Create event: 1
Last Year
- Release event: 1
- Watch event: 2
- Push event: 13
- Create event: 1