Understanding Black-box Predictions via Influence Functions
TL;DR. Which training examples made the model predict this? Retraining without each example would answer the question but is far too expensive. Influence functions, a tool from robust statistics, estimate the effect of upweighting one training example from gradients and an inverse-Hessian-vector product. Koh and Liang make this practical for modern models. Grosse et al. (2023) scale it to language models with up to 52B parameters.
Key idea
Section titled “Key idea”With training loss , minimiser and Hessian :
Removing changes the test loss by about . Forming costs . Instead, compute once with Hessian-vector products and conjugate gradients or LiSSA. Each training point then needs one gradient and a dot product (§2–3).
Key results
Section titled “Key results”Koh and Liang compare an RBF SVM and Inception v3 with all layers but the top frozen, on 900 training images per class of dogs versus fish. In the SVM, influence falls off with pixel distance. In Inception, it is much less tied to distance, which shows the models generalise differently (§5.1). Small, targeted perturbations to training images can flip predictions on chosen test images (§5.2). Grosse et al. apply EK-FAC to pretrained models from 810M to 52B parameters. For an “AI shutdown” query, the 810M model’s top sequences share tokens such as “continue” and “existing”. The 52B model’s top sequences share little wording but relate in theme. Influence is spread roughly evenly across layers, with middle layers capturing more abstract patterns. Training sequences matter only when prompt-related phrases come before completion-related ones.
Connections
Section titled “Connections”- SHAP: attributes to input features; influence attributes to training examples.
- In-context Learning and Induction Heads: a bottom-up, mechanism-level view of how models generalise, which Grosse et al. contrast with their top-down approach.
- Open Problems in Mechanistic Interpretability: where data attribution fits among interpretability tools.
- Reward hacking survey: tracing undesired behaviours back to data.
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.
- Derive / compute
Starting from θ̂_ε = argmin (1/n) Σ L(zᵢ, θ) + ε L(z, θ), derive the influence of upweighting z on the parameters and on the test loss. Then explain why removing z corresponds to ε = −1/n and what the formula predicts for the change in test loss.
What a strong answer covers
- At the optimum the gradient is zero. A first-order Taylor expansion of the optimality condition around θ̂ gives dθ̂_ε/dε at ε = 0 equal to −H⁻¹ ∇_θ L(z, θ̂), where H is the Hessian of the average training loss. This is I_up,params(z).
- By the chain rule, I_up,loss(z, z_test) = ∇_θ L(z_test, θ̂)ᵀ · I_up,params(z) = −∇L(z_test)ᵀ H⁻¹ ∇L(z).
- Removing z is the same as giving it weight −1/n relative to the original objective, so the predicted change in test loss is −(1/n) · I_up,loss(z, z_test).
- Assumptions: H is positive definite, the loss is twice differentiable and θ̂ is the minimiser; the paper adds damping and smooth approximations when these fail (§4.2–4.3).
- Mechanism
Explicitly forming and inverting the Hessian costs O(np² + p³). Explain how Koh and Liang avoid that, why computing s_test = H⁻¹ ∇L(z_test) once is the key trick, and what Grosse et al. change to reach 52B-parameter models.
What a strong answer covers
- Use Hessian-vector products (Pearlmutter), which cost about as much as a gradient, inside conjugate gradients or the LiSSA stochastic estimator to approximate H⁻¹v without forming H.
- s_test depends only on the test point. Once it is computed, the influence of every training point is a dot product −s_testᵀ ∇L(zᵢ), one gradient per training example.
- LiSSA with a few repeats was accurate on MNIST logistic regression without visiting every training point (§4.1).
- Grosse et al. replace iterative solvers with an EK-FAC approximation of the Hessian, which they report is as accurate as LiSSA and much faster, and add TF-IDF filtering and query batching to cut the cost of gradients over the pretraining set.
- Research idea
Grosse et al. find that influential training sequences for an 810M model share surface tokens with the query, while those for a 52B model relate more abstractly, and that influence nearly vanishes when key phrases appear in the opposite order. Propose a study applying influence functions to a retrieval-augmented LLM to ask whether its answers come from retrieved passages or from pretraining data.
What a strong answer covers
- Two sources of influence: the prompt context (retrieved passages, measurable by ablation or attribution) and the training data (measurable by influence functions on the model weights).
- Hypothesis example: for questions about rare facts, removing the retrieved passage changes the answer a lot and training influence is spread thin; for common facts, a few training sequences dominate.
- Method: compute influence of pretraining (or fine-tuning) sequences on the answer log-probability with and without the passage in context; compare concentration (for example top-k influence share) across the two conditions and across model sizes.
- Controls: the ordering sensitivity means paraphrased or reordered training sequences may be missed, so test recall with planted documents of known content.
- Limitations: influence estimates are approximate for non-convex models and Grosse et al. study pretrained, not RLHF-tuned, models.