captum
Model Interpretability for PyTorch
What it is and what it does
Captum is a PyTorch library for understanding and interpreting neural network predictions by computing attribution scores that show which input features, neurons, or training examples contribute most to a model's output. It implements state-of-the-art interpretability algorithms including Integrated Gradients, DeepLift, TCAV, and TracIn influence functions, along with adversarial perturbation capabilities for generating counterfactual explanations.
The library is designed for model developers who need to debug and improve their models, interpretability researchers benchmarking new algorithms, and production engineers troubleshooting model behavior. It integrates with domain-specific PyTorch libraries like torchvision and torchtext, and provides convergence metrics to assess approximation quality for gradient-based attribution methods.
Use it for:
- Debug unexpected model predictions by identifying which input features most influenced the output.
- Validate that a model learned meaningful patterns rather than spurious correlations in training data.
- Generate explanations for end users on why a model made a specific recommendation or classification decision.
- Benchmark new interpretability algorithms against established methods in the Captum library.
- Identify important neurons and layers within a network to guide model compression or architecture redesign.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Captum provides model interpretability algorithms for PyTorch, including integrated gradients, saliency maps, and other attribution methods to understand which features and training examples drive model predictions.
Yes. Captum is a production-stable, actively maintained library from PyTorch with no known vulnerabilities, low install friction, and permissive licensing. It is the standard choice for PyTorch model interpretability and is worth installing if you need to understand or explain neural network predictions.
Install
captum on PyPI
pip
pip install captumuv
uv add captumpoetry
poetry add captumInstalling captum
Before you install
Low install friction with a pure-Python wheel. Active maintenance with recent releases; last commit 2026-08-14. Requires PyTorch >= 2.3 and Python >= 3.10, which are standard modern versions.
License in practice
BSD-3-Clause permissive license allows commercial and private use with attribution and liability disclaimers.
Quickstart
pip install captum
import torch
from captum.attr import IntegratedGradients
model = torch.nn.Linear(3, 2)
ig = IntegratedGradients(model)
input_tensor = torch.rand(1, 3)
baseline = torch.zeros(1, 3)
attributions = ig.attribute(input_tensor, baseline, target=0)
Requires PyTorch >= 2.3 and Python >= 3.10.
Verify before relying
- Whether all interpretability algorithms scale efficiently to very large models or datasets.
- Specific performance characteristics or computational overhead compared to alternative attribution methods.
- Compatibility with non-standard PyTorch model architectures or custom layers.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — matplotlib, numpy, packaging, torch, tqdm |
| Maintenance | actively maintained — 119 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 548,326/month — #6,064 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: captum-0.9.0-py3-none-any.whl
Keywords: Model Interpretability, Model Understanding, Feature Importance, Neuron Importance, Data Attribution, Explainable AI, PyTorch
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
sae-lensSAE Lens trains and analyzes sparse…
permissive · top 15,000 on PyPI
entmaxEntmax provides PyTorch implementations of…
permissive · top 15,000 on PyPI
interpret-coreTrains interpretable machine learning models…
unclear · top 5,000 on PyPI
interpretInterpretML provides interpretable machine…
unclear · top 15,000 on PyPI
shapSHAP computes Shapley values to explain…
permissive · top 5,000 on PyPI
limeLime explains individual predictions from any…
permissive · top 15,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
pytorch_revgradImplements a gradient reversal layer for…
permissive · top 15,000 on PyPI
pytorch-forecastingPyTorch Forecasting provides neural network…
permissive · top 15,000 on PyPI
stable-baselines3Stable Baselines3 provides PyTorch…
permissive · top 5,000 on PyPI