skillfed

captum

Model Interpretability for PyTorch

captum v0.9.0 548.3K downloads/30d#6,064 on PyPI5,685
Permissive license BSD-3-Clause Active released

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 captum

uv

uv add captum

poetry

poetry add captum

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchProgramming Language :: Python :: 3 :: OnlyTopic :: Scientific/Engineering

Tags

pytorch model interpretabilityfeature attribution neural networksintegrated gradients pytorchexplainable ai pytorchmodel explanation algorithmssaliency maps pytorchneural network feature importance
model-explainabilitypytorch-ecosysteminterpretability

More Scientific/Engineering packages