Citation and evidence

Captum

14 min full readUpdated 26 references

This article's verification

Report a problem with this article

Edit article
More

Use this article

Raw MarkdownExplore connections

Improve this page

Revision historyDiscuss this article

Topics

Developer ToolsInterpretabilityMeta AIOpen Source AI

Cite this article

Captum is an open-source model interpretability library for PyTorch, developed by Facebook AI (now Meta AI) and released in October 2019 alongside PyTorch 1.3. [1][3] It provides general-purpose implementations of attribution algorithms, which estimate how much each input feature, hidden neuron or layer contributes to a model's output, together with evaluation metrics for those attributions. [3] Later releases added concept-based interpretability, adversarial robustness tools, training-data influence methods and an API for attributing the output of large language models to parts of a prompt. [15][17][4] The project's README says the name means "comprehension" in Latin. [7]

The library is distributed under the BSD 3-Clause license and published on PyPI as captum. [8][9] As of November 2026 the current release was v0.9.0 (April 2026), and the GitHub repository, hosted under the meta-pytorch organization, had about 5,700 stars. [8][10]

History

Facebook announced Captum on October 10, 2019, in the same blog post that introduced PyTorch 1.3, describing it as a tool to help PyTorch developers understand why a model generates a specific output. [1] The announcement listed integrated gradients, conductance, SmoothGrad, VarGrad and DeepLift among its algorithms. [1] VentureBeat reported that Joe Spisak, a product manager for PyTorch, said Captum had been used inside Facebook to better understand decisions made in multimodal settings before it was open-sourced. [2] The first tagged release, v0.1.0, appeared on GitHub the same day and also shipped Captum Insights, a visualization tool. [11]

In September 2020 Narine Kokhlikyan, Vivek Miglani and nine Facebook AI colleagues posted a paper describing the library's design on arXiv; the README lists it under the ICLR 2021 workshop on responsible AI. [3][7] A second paper from Meta AI, presented at the NLP Open Source Software workshop (NLP-OSS 2023) in December 2023, described the language model attribution features added in v0.7. [6]

VersionRelease dateMain additions
0.1.02019-10-10Gradient-based attribution (primary, layer and neuron), NoiseTunnel, Captum Insights [11]
0.2.02020-03-06Perturbation methods (feature ablation, feature permutation, occlusion, Shapley value sampling), GradCAM variants, type hints [12]
0.3.02020-11-13LIME, KernelSHAP, infidelity and sensitivity metrics [13]
0.3.12021-01-23Multi-layer LayerIntegratedGradients, model comparison in Insights [14]
0.4.02021-07-07TCAV, robustness tools (FGSM, PGD, attack comparator, minimal perturbation), LRP [15]
0.4.12021-11-02Robustness and TCAV tutorials [16]
0.5.02022-03-04Influential examples (TracInCP family) [17]
0.6.02022-12-28Stochastic gates, TracInCP improvements [18]
0.7.02023-12-05LLM attribution API, DataLoader attribution [4]
0.8.02025-03-27Influence functions, asynchronous attribution, more LLM attribution methods [5]
0.9.02026-04-17Remote LLM attribution via vLLM, image-mask inputs, Captum Insights removed, NumPy 2.x support [10]

Expanded article table

"Model Understanding with Captum", official video from PyTorch Foundation, published April 12, 2021. Watch on YouTube.

Design

The 2020 paper names multimodality, extensibility and ease of use as the library's three main characteristics. [3] Every algorithm follows the same API and signature: an attribution object wraps a model (or a model and a layer) and exposes an attribute method, so a user can switch between methods with little code change. [3][7] The authors argued that existing attribution frameworks such as DeepExplain, Alibi and InterpretML had insufficient support for PyTorch models, and that most model-understanding research had concentrated on computer vision, leaving a need for implementations that work across domains. [3]

Several algorithms, including integrated gradients, DeepLIFT, the SHAP variants, feature ablation and occlusion, need a baseline (also called a reference) that represents the absence of a feature, such as a black image; the paper notes that attribution quality depends on this choice, which is left to the user. [3] Methods that rest on the completeness property, the requirement that attributions sum to the difference between the model's output at the input and at the baseline, can also return a convergence delta, which the README describes as an estimate of the approximation error of the integral. [3][7] In the current source code, IntegratedGradients defaults to 50 integration steps using the Gauss-Legendre method. [19]

Scalability

Algorithms such as integrated gradients and layer conductance expand their inputs internally by the number of integration steps, which can exhaust memory. Captum handles this with an internal_batch_size argument that splits the work into batches of that size, runs forward and backward passes on each, and combines the results. [3][11] Since v0.3.0 these batches are generated lazily instead of by splitting an already expanded input tensor. [13] Perturbation methods can instead evaluate several perturbed copies of an input in one batch when memory allows. [3] All algorithms support PyTorch's DataParallel for running passes across several GPUs. [3][11]

The paper reports timings on a pretrained VGG model (VGG19) with one 3 x 224 x 224 image, on a machine with eight 16 GB GPUs; integrated gradients used 2,990 approximation steps. [3]

GPUsIntegrated gradients (s)Feature ablation (s)
141.62140.4
426.4138.39
815.0622.02

Expanded article table

Attribution algorithms

Captum groups its attribution methods into three kinds. Primary attribution assigns a model's output to its input features; layer attribution assigns the output to every neuron in a chosen hidden layer; neuron attribution assigns the activity of one hidden neuron to the model's inputs. [3] Most methods are either gradient-based or perturbation-based. Perturbation methods compute attributions by evaluating the model on altered versions of the input instead of using gradients. [3][12] The paper notes that some methods, such as GradCAM and Guided GradCAM, only make sense for convolutional models. [3]

FamilyMethods in the API reference (as of November 2026)
Primary attributionIntegrated Gradients, Saliency, DeepLift, DeepLiftShap, GradientShap, Input X Gradient, Guided Backprop, Guided GradCAM, Deconvolution, Feature Ablation, Occlusion, Feature Permutation, Shapley Value Sampling, Lime, KernelShap, BaselineKernelShap, RandomBaselineKernelShap, LRP [20]
Layer attributionLayer Conductance, Layer Activation, Internal Influence, Layer Gradient X Activation, GradCAM, Layer DeepLift, Layer DeepLiftShap, Layer GradientShap, Layer Integrated Gradients, Layer Feature Ablation, Layer Feature Permutation, Layer LRP [20]
Neuron attributionNeuron Gradient, Neuron Integrated Gradients, Neuron Conductance, Neuron DeepLift, Neuron DeepLiftShap, Neuron GradientShap, Neuron Guided Backprop, Neuron Deconvolution, Neuron Feature Ablation [20]

Expanded article table

The README links each method to its source paper. Integrated gradients follows Sundararajan and colleagues (2017), the SHAP-based gradient methods follow Lundberg and Lee (2017), saliency maps follow Simonyan and colleagues (2014), and Shapley value sampling follows the sampling approximation of Castro and colleagues (2009) to the Shapley value. [6][7] Layer-wise relevance propagation arrived in v0.4.0, and the release notes credit a community contributor for it. [15]

Noise tunnel

NoiseTunnel wraps another attribution method, adds Gaussian noise to the input and aggregates the attributions computed on the noisy samples, which is meant to reduce noise in the attribution map. It implements SmoothGrad, SmoothGrad Squared and VarGrad, and can be combined with most of the library's attribution algorithms. [3][21]

Evaluation metrics

Because visual explanations can mislead and many quantitative evaluations depend on the dataset domain, the library includes two metrics from Yeh and colleagues (2019), infidelity and maximum sensitivity, implemented so they work with any PyTorch model and most Captum algorithms. [3][22] They were added to the captum.metrics module in v0.3.0. [13]

Infidelity measures how far the attributions fail to predict the change in model output under perturbation. For an input $x$, a model $F$, an attribution function $\Phi$ and random perturbations $I$ drawn from a distribution $\mu_I$, the Captum paper defines it as [3]

INFD(Φ,F,x)=EI∼μI[(ITΦ(F,x)−(F(x)−F(x−I)))2]\mathrm{INFD}(\Phi, F, x) = \mathbb{E}_{I \sim \mu_I}\left[\left(I^{T}\Phi(F, x) - \left(F(x) - F(x - I)\right)\right)^2\right]

Maximum sensitivity measures how much an explanation changes when the input moves slightly. For a perturbed input $y$ within radius $r$ of $x$, the paper writes it as [3]

SENSMAX(Φ,F,x,r)=max⁡∥y−x∥≤r∥Φ(F,y)−Φ(F,x)∥∥Φ(F,x)∥\mathrm{SENS}_{\mathrm{MAX}}(\Phi, F, x, r) = \max_{\lVert y - x \rVert \le r} \frac{\lVert \Phi(F, y) - \Phi(F, x) \rVert}{\lVert \Phi(F, x) \rVert}

Captum estimates it by Monte Carlo sampling; by default it samples uniformly from an $L_\infty$ ball, and users can supply other perturbation functions. [3] In a 2021 follow-up, members of the team ran sanity checks for saliency maps on text classifiers, analyzed the results with these two metrics among others, and reported that conclusions drawn for images did not transfer directly to text. [23]

Beyond feature attribution

The 2020 paper listed adversarial robustness and concept-based interpretability as future work, and both arrived in v0.4.0 in July 2021. [3][15]

AreaModule contentsAdded
Concept-based interpretabilityTCAV (Testing with Concept Activation Vectors), which tests how much a user-defined concept matters to a prediction, for any modality [15][24]v0.4.0
RobustnessFast Gradient Sign Method and Projected Gradient Descent adversarial attacks; Attack Comparator for measuring the effect of any perturbation or attack; Minimal Perturbation for finding the smallest change that causes a misclassification [15]v0.4.0
Influential examplesTracInCP, TracInCPFast and TracInCPFastRandProj, which estimate how much a training example affects the loss on a test example [17][25]v0.5.0
Influence functionsNaiveInfluenceFunction and ArnoldiInfluenceFunction [5]v0.8.0
Stochastic gatesBinaryConcreteStochasticGates and GaussianStochasticGates in captum.module, for sparsity through an approximate L0 regularization [18]v0.6.0

Expanded article table

The TracIn implementations can identify "proponents" and "opponents" (training examples with the most positive or negative influence on a test prediction) and help find mislabeled training data. [17] The influence function classes compute the score $\nabla_\theta L(x)^{T} H^{-1} \nabla_\theta L(z)$, where $\nabla_\theta L(x)$ and $\nabla_\theta L(z)$ are loss gradients for a training example and a test example with respect to model parameters $\theta$, and $H$ is the Hessian with respect to those parameters at a given model checkpoint. [5] Both classes approximate $H^{-1}$ with its top eigenvectors; the naive class forms the Hessian explicitly, while the Arnoldi class, following Schioppa and colleagues, finds the eigenvectors through Arnoldi iteration without building the full matrix. [5]

Language model attribution

Captum v0.7.0 (December 2023) added wrappers for attributing the output of generative language models to parts of the prompt. [4] LLMAttribution pairs a perturbation-based method (feature ablation, LIME, KernelSHAP or Shapley value sampling) with a tokenizer, and LLMGradientAttribution does the same for gradient methods such as layer integrated gradients. [6] Users define the units of attribution as words, tokens, phrases or whole sentences through a text template, and supply baselines for each unit. [6]

The NLP-OSS paper argued that perturbing single tokens often produces text outside the natural input distribution, and recommended baselines that keep the prompt coherent, for example replacing one city with another rather than deleting it. [6] Its example template varies a name, city, state, occupation and pronoun ("Dave lives in Palm Coast, FL and is a lawyer. His personal interests include") against baselines such as "Sarah", "Seattle", "WA", "doctor" and "Her". [4][6] The target can be a string chosen by the user, in which case the attributed quantity is the log probability of that string; by default it is the model's most likely decoded output. [6] Gradient methods attribute to the embedding layer's output, since token lookups are not differentiable, and aggregate across embedding dimensions to give a score per token. [6]

The paper reported two example uses. With Shapley value sampling, the male name and pronoun in the template had positive attribution toward "golfing" and negative attribution toward "cooking", which the authors flagged as a potentially biased association. [6] In a few-shot sentiment prompt, all four example demonstrations reduced the model's confidence in the correct "Positive" label. [6] The authors contrasted Captum with the text attribution libraries Ecco and Inseq, which they described as built on Captum's attribution methods and focused on gradient-based, token-level attribution. [6]

Version 0.8.0 (March 2025) added layer gradient X activation and layer gradient SHAP to the gradient-based LLM wrapper, support for key-value caching in perturbation-based LLM attribution, and a tutorial on Llama 2. [5] Version 0.9.0 (April 2026) added RemoteLLMAttribution and a VLLMProvider, which run perturbation-based attribution against a model hosted on a vLLM server so the model no longer has to fit in the client process. [10] The same release introduced ImageMaskInput for attributing vision-language model outputs to user-defined image regions, with a tutorial that uses Meta's Segment Anything model to interpret Gemma 4. [10]

Captum Insights

Captum Insights was an interactive model-debugging tool built on top of the library and shipped with the first release. It could run inside a Jupyter notebook or as a standalone application, visualized attributions across sampled data for classification models, combined text, image and other features in one model, and filtered by class or by misclassified examples. [11] It was built with JavaScript, React and Flask. [11] At launch it supported only integrated gradients; [2] v0.2.0 added Google Colab support and more methods. [12] The Captum paper showed it applied to a multimodal visual question answering model, where it displayed the aggregate attribution for each modality. [3]

The v0.8.0 notes announced that Insights would be deprecated in the next major release, and v0.9.0 removed it along with the captum[insights] install option; the notes direct users who still need it to the v0.8.0 tag. [5][10]

Requirements and distribution

Captum is installed with pip install captum and is also packaged for conda. [7] The v0.9.0 release raised the minimum versions to Python 3.10 and PyTorch 1.13 and added NumPy 2.x support; [10] the README on the master branch listed PyTorch 2.3 or later as of November 2026. [7] PyPI lists the package author as the PyTorch Team. [9] The repository received commits as recently as November 17, 2026. [8]

The README names two primary audiences: model developers who want to improve their models by understanding which concepts, features or training examples matter, and interpretability researchers looking for algorithms that better interpret many types of models. It adds that the library lets researchers implement new algorithms and benchmark them against existing ones, and that application engineers can use it to troubleshoot models in production. [7] Inseq, an interpretability library for sequence generation models, describes its own set of attribution methods as extending the ones Captum supports. [26]

Continue reading

More to read

Topics:Developer ToolsInterpretabilityMeta AIOpen Source AI

References

  1. ^1 ^2 ^3PyTorch. "PyTorch 1.3 adds mobile, privacy, quantization, and named tensors". PyTorch Blog, October 10, 2019. pytorch.org/...vacy-quantization-and-named-tensors
  2. ^1 ^2Johnson, Khari. "Facebook's Captum brings explainability to machine learning". VentureBeat, October 10, 2019. venturebeat.com/...lainability-to-machine-learning
  3. ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8 ^9 ^10 ^11 ^12 ^13 ^14 ^15 ^16 ^17 ^18 ^19 ^20 ^21 ^22Kokhlikyan, Narine; Miglani, Vivek; Martin, Miguel; Wang, Edward; Alsallakh, Bilal; Reynolds, Jonathan; Melnikov, Alexander; Kliushkina, Natalia; Araya, Carlos; Yan, Siqi; Reblitz-Richardson, Orion. "Captum: A unified and generic model interpretability library for PyTorch". arXiv:2009.07896, September 16, 2020. arxiv.org/...2009.07896
  4. ^1 ^2 ^3 ^4Captum. "Captum v0.7.0 Release". GitHub, December 5, 2023. github.com/...v0.7.0
  5. ^1 ^2 ^3 ^4 ^5 ^6Captum. "Captum v0.8.0 Release". GitHub, March 27, 2025. github.com/...v0.8.0
  6. ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8 ^9 ^10 ^11Miglani, Vivek; Yang, Aobo; Markosyan, Aram H.; Garcia-Olano, Diego; Kokhlikyan, Narine. "Using Captum to Explain Generative Language Models". Proceedings of the 3rd Workshop for Natural Language Processing Open Source Software (NLP-OSS 2023), pages 165-173, Association for Computational Linguistics, December 6, 2023. aclanthology.org/2023.nlposs-1.19
  7. ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8Captum. "README.md". GitHub, meta-pytorch/captum, accessed November 18, 2026. github.com/...README.md
  8. ^1 ^2 ^3GitHub. "meta-pytorch/captum: Model interpretability and understanding for PyTorch". GitHub, accessed November 18, 2026. github.com/...captum
  9. ^1 ^2Python Package Index. "captum". PyPI, accessed November 18, 2026. pypi.org/...captum
  10. ^1 ^2 ^3 ^4 ^5 ^6Captum. "Captum v0.9.0 Release". GitHub, April 17, 2026. github.com/...v0.9.0
  11. ^1 ^2 ^3 ^4 ^5 ^6Captum. "Initial Release of Captum for Model Interpretability, Attribution and Debugging" (v0.1.0). GitHub, October 10, 2019. github.com/...v0.1.0
  12. ^1 ^2 ^3Captum. "Captum v0.2.0 Release". GitHub, March 6, 2020. github.com/...v0.2.0
  13. ^1 ^2 ^3Captum. "Captum v0.3.0 Release". GitHub, November 13, 2020. github.com/...v0.3.0
  14. ^Captum. "Captum v0.3.1 Release". GitHub, January 23, 2021. github.com/...v0.3.1
  15. ^1 ^2 ^3 ^4 ^5 ^6Captum. "Captum v0.4.0 Release". GitHub, July 7, 2021. github.com/...v0.4.0
  16. ^Captum. "Captum v0.4.1 Release". GitHub, November 2, 2021. github.com/...v0.4.1
  17. ^1 ^2 ^3 ^4Captum. "Captum v0.5.0 Release". GitHub, March 4, 2022. github.com/...v0.5.0
  18. ^1 ^2Captum. "Captum v0.6.0 Release". GitHub, December 28, 2022. github.com/...v0.6.0
  19. ^Captum. "captum/attr/_core/integrated_gradients.py". GitHub, meta-pytorch/captum, accessed November 18, 2026. github.com/...integrated_gradients.py
  20. ^1 ^2 ^3Captum. "Captum API Reference". captum.ai, accessed November 18, 2026. captum.ai/api
  21. ^Captum. "Algorithm Descriptions". captum.ai, accessed November 18, 2026. captum.ai/...attribution_algorithms
  22. ^Yeh, Chih-Kuan; Hsieh, Cheng-Yu; Suggala, Arun Sai; Inouye, David I.; Ravikumar, Pradeep. "On the (In)fidelity and Sensitivity for Explanations". arXiv:1901.09392, 2019. arxiv.org/...1901.09392
  23. ^Kokhlikyan, Narine; Miglani, Vivek; Alsallakh, Bilal; Martin, Miguel; Reblitz-Richardson, Orion. "Investigating sanity checks for saliency maps with image and text classification". arXiv:2106.07475, June 8, 2021. arxiv.org/...2106.07475
  24. ^Kim, Been; Wattenberg, Martin; Gilmer, Justin; Cai, Carrie; Wexler, James; Viegas, Fernanda; Sayres, Rory. "Interpretability Beyond Feature Attribution: Quantitative Testing with Concept Activation Vectors (TCAV)". arXiv:1711.11279, 2017. arxiv.org/...1711.11279
  25. ^Pruthi, Garima; Liu, Frederick; Sundararajan, Mukund; Kale, Satyen. "Estimating Training Data Influence by Tracing Gradient Descent". arXiv:2002.08484, 2020. arxiv.org/...2002.08484
  26. ^Inseq. "README.md". GitHub, inseq-team/inseq, accessed November 18, 2026. github.com/...inseq

Improve this article

Add missing citations, update stale details, or write a clearer explanation. Anyone can edit: changes go live when you publish, and every edit is checked by an editor.

2 revisions · v2 · 2,808 words · full history

Fact-checks are independent of edits: a reviewer re-verifies the article against its sources and stamps the date. How we verify

Research and drafting on this wiki are AI-assisted, under named human editorial standards. How AI is used here

Reviewer note: Independent fact-check before publication on November 18, 2026: 118 claims checked against 24 cited and independent sources; 0 material and 4 minor corrections applied before publication.

Cite this page: AI Wiki. "Captum." aiwiki.ai, updated 18 Nov 2026, fact-checked 18 Nov 2026. CC BY 4.0. https://aiwiki.ai/wiki/captum

Edit article