Skip to content

Axiomatic Attribution for Deep Networks

optionalcorefundamentalpaperrubric 11/122017 · ~40 min

Mukund Sundararajan, Ankur Taly, Qiqi Yan

Status

TL;DR. Integrated Gradients (IG) explains a prediction by comparing it with a baseline input. It averages the gradient along the straight line from the baseline to the input and multiplies by the input difference. The attributions then add up exactly to the change in output. The paper derives IG from axioms instead of proposing yet another heuristic.

Why it matters now. IG is still a standard first answer to “which tokens drove this score?”. It applies to rerankers, dense retrievers, reward models and LLM judges, as long as you can take gradients. Its axioms also give you a checklist for judging any newer attribution method. Its weak point, the baseline, is the question to ask of every attribution claim in an IR or RAG paper.

Let FF be the model output (for example one logit), xx the input and x′x' a baseline. For feature ii:

IGi(x)=(xi−xi′)∫01∂F(x′+α(x−x′))∂xi dα\mathrm{IG}_i(x) = (x_i - x'_i)\int_0^1 \frac{\partial F\big(x' + \alpha(x - x')\big)}{\partial x_i}\, d\alpha

Because this is a path integral of a gradient, the fundamental theorem of calculus gives completeness:

∑iIGi(x)=F(x)−F(x′)\sum_i \mathrm{IG}_i(x) = F(x) - F(x')

In practice the integral is a Riemann sum over mm points on the path. That costs mm gradient evaluations.

Integrated Gradients: integrate the gradient along a straight path from a baseline to the input Left: in input space, a straight path runs from the baseline x-prime to the input x; gradients are sampled at points along the path. Right: the model output along that path rises steeply and then saturates, so the gradient at the input itself is close to zero. Integrating the gradient over the whole path recovers the full change in output, which is the completeness property: the attributions sum to F of x minus F of x-prime. Straight path in input space feature x₁ feature x₂ x′ baseline (α = 0) input x (α = 1) ∇F sampled at x′ + α(x − x′) IGᵢ = (xᵢ − x′ᵢ) · ∫₀¹ ∂ᵢF(x′ + α(x − x′)) dα Riemann sum in practice: m = 20–300 steps Model output along the path α F(x′ + α(x − x′)) 0 1 flat near α = 1: ∇F(x) ≈ 0 plain gradient at x misses the rise Completeness: Σᵢ IGᵢ = F(x) − F(x′) the bracket is what the attributions share
Original sketch. A plain gradient at the input sees a flat (saturated) region and misses the change. Integrating along the path from the baseline recovers the whole change F(x) − F(x′), shared among the features.

The paper is axiomatic. Its evidence is a set of qualitative case studies (§6), not a benchmark table.

  • Object recognition (GoogleNet). IG maps on ImageNet images highlight the distinctive features of the predicted object (§6.1).
  • Diabetic retinopathy. Attributions localise to lesions in the retina. The interior of a lesion gets negative credit and its boundary positive credit, so the network attends to lesion edges (§6.2).
  • Question classification. On WikiTableQuestions-style questions, IG showed that “total number” pushes towards a numeric answer type. It also exposed a spurious trigger: the word “charles” pushed towards a yes/no answer (§6.3).
  • Neural machine translation. IG between output and input tokens recovers alignments. These models needed 100–1000 steps (§6.4).
  • Chemistry models. For a molecular graph convolution model, atom pairs with a bond carry 46% of one prediction. Identical attributions for differently bonded atoms exposed an architecture bug: features were not fully convolved (§6.5).
  • Baseline dependence. Different baselines give different attributions, and there is no principled choice for discrete text. The “absence of signal” ideal is easy to state and hard to realise.
  • Path dependence. The straight line is one choice among infinitely many paths. Its points can lie far from the data manifold, especially between a zero embedding and real token embeddings.
  • Faithfulness is not proven. The axioms constrain how credit is shared, not whether the explanation matches the model’s mechanism. Interactions between features are folded into first-order credit.
  • Cost. m gradient passes per explanation is costly for long inputs and large models.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    Take f(x) = 1 − ReLU(1 − x), baseline x′ = 0 and input x = 2. (a) Compute the plain gradient attribution x · f′(x). (b) Compute Integrated Gradients exactly. (c) Approximate IG with a right-endpoint Riemann sum using m = 4 steps, and explain why the answer depends on how you define the derivative of ReLU at 0.

    What a strong answer covers
    • (a) For x > 1 the function is flat at 1, so f′(2) = 0 and the gradient attribution is 0, even though f moved from f(0) = 0 to f(2) = 1. This is the paper's Sensitivity(a) counterexample.
    • (b) On the path z = 2α, f′(z) = 1 for z < 1 and 0 for z > 1. IG = (2 − 0) · ∫₀¹ f′(2α) dα = 2 · 0.5 = 1, which equals f(2) − f(0). Completeness holds.
    • (c) Points α = 0.25, 0.5, 0.75, 1 give z = 0.5, 1, 1.5, 2 with gradients 1, g(1), 0, 0, where g(1) is the derivative at the kink. The sum is (2/4)·(1 + g(1)), so 0.5 if g(1) = 0 and 1 if g(1) = 1.
    • Lesson: the Riemann sum only approximates completeness. The paper's recipe is to check that the attributions sum to F(x) − F(x′) and raise m if they do not (§5).
  2. Mechanism

    Explain why completeness, Σᵢ IGᵢ(x) = F(x) − F(x′), holds for Integrated Gradients, and why the same argument fails for DeepLIFT or LRP when two networks compute the same function with different internals.

    What a strong answer covers
    • IG is a path integral of the gradient along γ(α) = x′ + α(x − x′). By the fundamental theorem of calculus for path integrals, Σᵢ ∫ ∂F/∂xᵢ dγᵢ = F(γ(1)) − F(γ(0)). This needs F differentiable almost everywhere, which holds for ReLU networks.
    • Completeness implies Sensitivity(a): if the input and baseline differ only in one feature and the outputs differ, that feature gets non-zero attribution.
    • IG uses only true gradients of F, so it depends only on the function. Two functionally equivalent networks get identical attributions (implementation invariance).
    • DeepLIFT and LRP replace gradients with discrete ratios of differences. These do not obey the chain rule, so the attribution depends on how the computation is split into layers.
  3. Connect

    For F(x₁, x₂) = min(x₁, x₂) with baseline (0, 0) and input (1, 3), compute the Integrated Gradients attributions and the Shapley values (missing feature set to its baseline value). Explain where the difference comes from in terms of paths.

    What a strong answer covers
    • IG path: (α, 3α). Along it min = α, so ∂F/∂x₁ = 1 and ∂F/∂x₂ = 0. IG₁ = 1 · 1 = 1 and IG₂ = 0.
    • Shapley: v(∅) = 0, v({1}) = min(1, 0) = 0, v({2}) = min(0, 3) = 0, v({1,2}) = 1. Each feature gets ½ · (0 − 0) + ½ · (1 − 0) = ½.
    • Both satisfy completeness (sum = 1). Shapley–Shubik corresponds to averaging over the n! extremal paths that switch features on one at a time; IG uses the single diagonal path (Aumann–Shapley), as in Remark 5 of the paper.
    • On the diagonal, x₁ is always the binding minimum, so IG gives it all the credit. Neither answer is "wrong"; the choice of path is a modelling decision.
  4. Critique

    For text models the paper recommends the all-zero embedding as the baseline, noting it is not a valid input. What is the weakest assumption here, and what experiment would show whether IG token attributions for a BERT-style classifier are driven by the baseline rather than the input?

    What a strong answer covers
    • IG explains F(x) − F(x′), so every attribution is relative to the baseline. If F(x′) is far from a "no information" output, the attributions explain the wrong contrast. The paper asks for a near-zero score at the baseline.
    • The straight path from the zero vector to real embeddings passes through points the model never saw. Gradients there may reflect off-manifold behaviour, not the model's reasoning on real text.
    • Experiment: compute IG with several baselines (zero vector, [MASK] or [PAD] embeddings, average embedding, a random neutral sentence). Measure rank correlation of token attributions across baselines and check F(x′) for each.
    • Follow with a deletion or insertion test: remove the top-k attributed tokens and measure the drop in score. Compare which baseline's ranking predicts the drop best.
  5. Design

    You want to explain why a cross-encoder reranker scores a query–passage pair highly, with attributions over both query and passage tokens. Each pair is 512 tokens and you have one GPU. Design the IG setup: baseline, path, number of steps, sanity checks and cost.

    What a strong answer covers
    • Attribute the relevance logit, not a softmax over a candidate list, so the target is one scalar per pair.
    • Baseline options: zero embeddings for passage tokens only (keep the query fixed) to ask "which passage tokens matter given the query"; or a [PAD]/[MASK] baseline. State that results are relative to this choice.
    • Cost: m forward and backward passes per pair. With m = 50 and batching steps, this is about 50× a single scoring pass, so explain a sample of pairs, not the whole run.
    • Sanity checks: completeness error |Σ IG − (F(x) − F(x′))| should be small (raise m if not); deletion curves comparing IG with attention weights and with plain gradient × input.
    • Aggregate per word by summing sub-token attributions, since completeness makes sums meaningful.
  6. Research idea

    Propose a follow-up project on attributing an LLM-as-judge score (a single "relevance 0–3" token logit) to spans of the judged passage using IG. State a hypothesis, the minimal experiment, and the result that would falsify it.

    What a strong answer covers
    • Hypothesis example: judge scores are driven mostly by lexical overlap with the query, not by the passage's answer content.
    • Setup: compute IG over passage tokens for the logit of the chosen grade, with a fixed neutral baseline; mark query-term overlaps and gold answer spans.
    • Minimal experiment: compare attribution mass on overlap tokens and on answer spans across many judged pairs; then edit passages (remove the answer but keep overlap) and check whether the grade follows the attribution.
    • Falsifier: if attribution mass on answer spans dominates and answer-removal edits lower the grade as predicted, the overlap hypothesis is wrong.
    • Caveat to address: long inputs and the softmax over grade tokens make IG expensive and the baseline choice matters; report completeness error.

Done with this page?

Status