# Captum

> Source: https://aiwiki.ai/wiki/captum
> Updated: 2026-11-18
> Fact-checked: 2026-11-18
> Categories: Developer Tools, Interpretability, Meta AI, Open Source AI
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) - attribute to "AI Wiki (aiwiki.ai)"
> Cite as: AI Wiki. "Captum." aiwiki.ai, 18 Nov 2026. https://aiwiki.ai/wiki/captum
> From AI Wiki (https://aiwiki.ai), the free encyclopedia of artificial intelligence. Reuse freely with attribution.

**Captum** is an open-source model interpretability library for [PyTorch](https://aiwiki.ai/wiki/pytorch), developed by Facebook AI (now [Meta AI](https://aiwiki.ai/wiki/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](https://aiwiki.ai/wiki/large_language_model) 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]

| Version | Release date | Main additions |
|---|---|---|
| 0.1.0 | 2019-10-10 | Gradient-based attribution (primary, layer and neuron), NoiseTunnel, Captum Insights [11] |
| 0.2.0 | 2020-03-06 | Perturbation methods (feature ablation, feature permutation, occlusion, Shapley value sampling), GradCAM variants, type hints [12] |
| 0.3.0 | 2020-11-13 | LIME, KernelSHAP, infidelity and sensitivity metrics [13] |
| 0.3.1 | 2021-01-23 | Multi-layer LayerIntegratedGradients, model comparison in Insights [14] |
| 0.4.0 | 2021-07-07 | TCAV, robustness tools (FGSM, PGD, attack comparator, minimal perturbation), LRP [15] |
| 0.4.1 | 2021-11-02 | Robustness and TCAV tutorials [16] |
| 0.5.0 | 2022-03-04 | Influential examples (TracInCP family) [17] |
| 0.6.0 | 2022-12-28 | Stochastic gates, TracInCP improvements [18] |
| 0.7.0 | 2023-12-05 | LLM attribution API, DataLoader attribution [4] |
| 0.8.0 | 2025-03-27 | Influence functions, asynchronous attribution, more LLM attribution methods [5] |
| 0.9.0 | 2026-04-17 | Remote LLM attribution via vLLM, image-mask inputs, Captum Insights removed, NumPy 2.x support [10] |

<figure class="embedvideo">
<iframe src="https://www.youtube-nocookie.com/embed/Am2EF9CLu-g" title="Model Understanding with Captum"></iframe>
<figcaption>"Model Understanding with Captum", official video from PyTorch Foundation, published April 12, 2021. <a href="https://www.youtube.com/watch?v=Am2EF9CLu-g">Watch on YouTube</a>.</figcaption>
</figure>

## 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](https://aiwiki.ai/wiki/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](https://aiwiki.ai/wiki/gpu). [3][11]

The paper reports timings on a pretrained [VGG](https://aiwiki.ai/wiki/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]

| GPUs | Integrated gradients (s) | Feature ablation (s) |
|---|---|---|
| 1 | 41.62 | 140.4 |
| 4 | 26.41 | 38.39 |
| 8 | 15.06 | 22.02 |

## 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]

| Family | Methods in the API reference (as of November 2026) |
|---|---|
| Primary attribution | [Integrated Gradients](https://aiwiki.ai/wiki/integrated_gradients), Saliency, DeepLift, DeepLiftShap, GradientShap, Input X Gradient, Guided Backprop, Guided GradCAM, Deconvolution, Feature Ablation, Occlusion, Feature Permutation, Shapley Value Sampling, [Lime](https://aiwiki.ai/wiki/lime), KernelShap, BaselineKernelShap, RandomBaselineKernelShap, [LRP](https://aiwiki.ai/wiki/lrp) [20] |
| Layer attribution | Layer Conductance, Layer Activation, Internal Influence, Layer Gradient X Activation, [GradCAM](https://aiwiki.ai/wiki/grad_cam), Layer DeepLift, Layer DeepLiftShap, Layer GradientShap, Layer Integrated Gradients, Layer Feature Ablation, Layer Feature Permutation, Layer LRP [20] |
| Neuron attribution | Neuron Gradient, Neuron Integrated Gradients, Neuron Conductance, Neuron DeepLift, Neuron DeepLiftShap, Neuron GradientShap, Neuron Guided Backprop, Neuron Deconvolution, Neuron Feature Ablation [20] |

The README links each method to its source paper. Integrated gradients follows Sundararajan and colleagues (2017), the [SHAP](https://aiwiki.ai/wiki/shap)-based gradient methods follow Lundberg and Lee (2017), [saliency maps](https://aiwiki.ai/wiki/saliency_map) follow Simonyan and colleagues (2014), and Shapley value sampling follows the sampling approximation of Castro and colleagues (2009) to the [Shapley value](https://aiwiki.ai/wiki/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](https://aiwiki.ai/wiki/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]

$$\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]

$$\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]

| Area | Module contents | Added |
|---|---|---|
| Concept-based interpretability | TCAV (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 |
| Robustness | Fast Gradient Sign Method and Projected Gradient Descent [adversarial attacks](https://aiwiki.ai/wiki/adversarial_attack); 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 examples | TracInCP, TracInCPFast and TracInCPFastRandProj, which estimate how much a training example affects the loss on a test example [17][25] | v0.5.0 |
| Influence functions | NaiveInfluenceFunction and ArnoldiInfluenceFunction [5] | v0.8.0 |
| Stochastic gates | BinaryConcreteStochasticGates and GaussianStochasticGates in `captum.module`, for sparsity through an approximate [L0 regularization](https://aiwiki.ai/wiki/l0_regularization) [18] | v0.6.0 |

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](https://aiwiki.ai/wiki/influence_functions) 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](https://aiwiki.ai/wiki/tokenization), 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](https://aiwiki.ai/wiki/few-shot_learning) 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](https://aiwiki.ai/wiki/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](https://aiwiki.ai/wiki/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](https://aiwiki.ai/wiki/segment_anything_model_and_dataset_sam_and_sa-1b) model to interpret [Gemma 4](https://aiwiki.ai/wiki/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](https://aiwiki.ai/wiki/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]

## See also

- [Interpretability](https://aiwiki.ai/wiki/interpretability)
- [Explainable AI](https://aiwiki.ai/wiki/explainable_ai)
- [Feature importances](https://aiwiki.ai/wiki/feature_importances)
- [Feature attribution](https://aiwiki.ai/wiki/feature_attribution)
- [Mechanistic interpretability](https://aiwiki.ai/wiki/mechanistic_interpretability)

## References

1. PyTorch. "PyTorch 1.3 adds mobile, privacy, quantization, and named tensors". PyTorch Blog, October 10, 2019. https://pytorch.org/blog/pytorch-1-dot-3-adds-mobile-privacy-quantization-and-named-tensors/
2. Johnson, Khari. "Facebook's Captum brings explainability to machine learning". VentureBeat, October 10, 2019. https://venturebeat.com/technology/facebooks-captum-brings-explainability-to-machine-learning
3. Kokhlikyan, 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. https://arxiv.org/abs/2009.07896
4. Captum. "Captum v0.7.0 Release". GitHub, December 5, 2023. https://github.com/meta-pytorch/captum/releases/tag/v0.7.0
5. Captum. "Captum v0.8.0 Release". GitHub, March 27, 2025. https://github.com/meta-pytorch/captum/releases/tag/v0.8.0
6. Miglani, 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. https://aclanthology.org/2023.nlposs-1.19/
7. Captum. "README.md". GitHub, meta-pytorch/captum, accessed November 18, 2026. https://github.com/meta-pytorch/captum/blob/master/README.md
8. GitHub. "meta-pytorch/captum: Model interpretability and understanding for PyTorch". GitHub, accessed November 18, 2026. https://github.com/meta-pytorch/captum
9. Python Package Index. "captum". PyPI, accessed November 18, 2026. https://pypi.org/project/captum/
10. Captum. "Captum v0.9.0 Release". GitHub, April 17, 2026. https://github.com/meta-pytorch/captum/releases/tag/v0.9.0
11. Captum. "Initial Release of Captum for Model Interpretability, Attribution and Debugging" (v0.1.0). GitHub, October 10, 2019. https://github.com/meta-pytorch/captum/releases/tag/v0.1.0
12. Captum. "Captum v0.2.0 Release". GitHub, March 6, 2020. https://github.com/meta-pytorch/captum/releases/tag/v0.2.0
13. Captum. "Captum v0.3.0 Release". GitHub, November 13, 2020. https://github.com/meta-pytorch/captum/releases/tag/v0.3.0
14. Captum. "Captum v0.3.1 Release". GitHub, January 23, 2021. https://github.com/meta-pytorch/captum/releases/tag/v0.3.1
15. Captum. "Captum v0.4.0 Release". GitHub, July 7, 2021. https://github.com/meta-pytorch/captum/releases/tag/v0.4.0
16. Captum. "Captum v0.4.1 Release". GitHub, November 2, 2021. https://github.com/meta-pytorch/captum/releases/tag/v0.4.1
17. Captum. "Captum v0.5.0 Release". GitHub, March 4, 2022. https://github.com/meta-pytorch/captum/releases/tag/v0.5.0
18. Captum. "Captum v0.6.0 Release". GitHub, December 28, 2022. https://github.com/meta-pytorch/captum/releases/tag/v0.6.0
19. Captum. "captum/attr/_core/integrated_gradients.py". GitHub, meta-pytorch/captum, accessed November 18, 2026. https://github.com/meta-pytorch/captum/blob/master/captum/attr/_core/integrated_gradients.py
20. Captum. "Captum API Reference". captum.ai, accessed November 18, 2026. https://captum.ai/api/
21. Captum. "Algorithm Descriptions". captum.ai, accessed November 18, 2026. https://captum.ai/docs/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. https://arxiv.org/abs/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. https://arxiv.org/abs/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. https://arxiv.org/abs/1711.11279
25. Pruthi, Garima; Liu, Frederick; Sundararajan, Mukund; Kale, Satyen. "Estimating Training Data Influence by Tracing Gradient Descent". arXiv:2002.08484, 2020. https://arxiv.org/abs/2002.08484
26. Inseq. "README.md". GitHub, inseq-team/inseq, accessed November 18, 2026. https://github.com/inseq-team/inseq
