Attribution and Training-Data Transparency › Influence Estimation: From Documentation to Evidence

Michael BrenndoerferNovember 26, 202612 min read
Language AI HandbookAll chapters
Part 21 of 67Data Governance, Provenance, and Synthetic Ecosystems
Chapter 151Attribution and Training-Data Transparency › Influence Estimation: From Documentation to Evidence
Reading section 4 of 10 · Influence Estimation: From Documentation to Evidence · 12 minSection 4 of 10 · 12 min

Section 4 of 10 · 12 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Documentation tells us what data exists. Influence estimation asks how the model’s behavior would change if a training example were removed, downweighted, or added. Refitting on the changed data gives a direct comparison under a specified training protocol. At large model scales, repeating that refit for every training example can be prohibitively expensive. Some objectives admit exact deletion updates. In ridge least squares with a fixed positive penalty and the original sample divisor, the normal equations use the sum of feature outer products and the sum of features times their targets. Subtract the removed row’s contribution from each sum and solve the updated system with the same penalty. Guo et al. (2020), sections 3.1–3.2 derive a one-step Newton removal approximation for a convex linear-model loss with strongly convex L2 regularization. The step uses the remaining-data objective. Their gradient-residual bound also assumes a Lipschitz second derivative and bounded features and gradients.

The framing here is deliberately causal. Documentation is a statement about the contents of a dataset. Influence estimation is an attempt to answer a counterfactual question about the training process: what would have happened if this example had not been there? That question is well defined in principle and very expensive in practice. The rest of this section is about how far we can get with approximations, and what those approximations cost us.

The counterfactual question

Let the training set be z1,…,znz_1,\dots,z_n, where each zi=(xi,yi)z_i=(x_i,y_i) is an input-output pair or, for language modeling, a token sequence and its next-token targets. Define the empirical risk

R(θ)=1n∑i=1nL(zi;θ)+λ2∥θ∥22,R(\theta) = \frac{1}{n}\sum_{i=1}^{n} L(z_i;\theta) + \frac{\lambda}{2}\|\theta\|_2^2,

where LL is the per-example loss and λ\lambda is an L2 regularization strength. Let

θ^=arg⁡min⁡θR(θ)\hat{\theta} = \arg\min_{\theta} R(\theta)

be the trained parameters. For a test example ztestz_{\text{test}}, define the test loss Ltest(θ)=L(ztest;θ)L_{\text{test}}(\theta)=L(z_{\text{test}};\theta). The leave-one-out effect of training example ii is

Δi=Ltest(θ^−i)−Ltest(θ^),\Delta_i = L_{\text{test}}(\hat{\theta}_{-i}) - L_{\text{test}}(\hat{\theta}),

where θ^−i\hat{\theta}_{-i} is the model retrained without example ii. A positive Δi\Delta_i means removing the example increases test loss, so the example was helpful for this test point. A negative Δi\Delta_i means removing the example decreases test loss, so the example was harmful for this test point.

It is worth dwelling on the direction of the inequality, because this is where most readers first get lost. The quantity Δi\Delta_i compares two models: the model trained on the full data, and the same model retrained without example ii. If the test loss goes up when we remove the example, the full model was better at this test point because of that example, so we describe the example as helpful. If the test loss goes down when we remove the example, the example was actively hurting the full model at this test point, so we describe it as harmful. "Helpful" and "harmful" are always relative to a chosen test point and a chosen loss. The same example can be helpful for one test point and harmful for another, which is the target-specificity theme that runs through the whole chapter.

Directly evaluating Δi\Delta_i by separate refits uses one optimization run per removed example. Influence functions approximate Δi\Delta_i with gradients and a Hessian.

Repeated refits cost time, and training randomness can make their results hard to compare. Hold the training protocol fixed, pair the seeds where possible, and repeat the comparison if the target is an effect across training runs. Influence estimation uses a local linear approximation at the fitted model to estimate the effect of changing an example’s weight without another refit.

The influence function approximation

Set the weight of example ii to zero, leaving the original divisor nn and regularization strength λ\lambda fixed. This is the deletion convention used in the worked refits. Averaging over the remaining n−1n-1 examples rescales the data term relative to the fixed penalty when λ>0\lambda>0; if λ=0\lambda=0, the two objectives differ only by an overall positive scale.

R−i(θ)=R(θ)−1nL(zi;θ).R_{-i}(\theta) = R(\theta) - \frac{1}{n}L(z_i;\theta).

At the trained parameters θ^\hat{\theta}, the gradient of the full risk is zero:

∇R(θ^)=0.\nabla R(\hat{\theta})=0.

Therefore the gradient of the leave-one-out risk at θ^\hat{\theta} is

∇R−i(θ^)=−1n∇L(zi;θ^).\nabla R_{-i}(\hat{\theta}) = -\frac{1}{n}\nabla L(z_i;\hat{\theta}).

Let

H=∇2R(θ^)=1n∑j=1n∇2L(zj;θ^)+λIH = \nabla^2 R(\hat{\theta}) = \frac{1}{n}\sum_{j=1}^{n}\nabla^2 L(z_j;\hat{\theta}) + \lambda I

be the Hessian of the regularized empirical risk at the optimum. Write Rϵ(θ)=R(θ)+ϵL(zi;θ)R_\epsilon(\theta)=R(\theta)+\epsilon L(z_i;\theta), with the separate regularizer held fixed, and let θ^ϵ\hat{\theta}_\epsilon be the stationary branch through θ^\hat{\theta} at ϵ=0\epsilon=0. Differentiating ∇Rϵ(θ^ϵ)=0\nabla R_\epsilon(\hat{\theta}_\epsilon)=0 at zero gives H dθ^ϵ/dϵ=−∇L(zi;θ^)H\,d\hat{\theta}_\epsilon/d\epsilon=-\nabla L(z_i;\hat{\theta}) there. The first-order response in ϵ\epsilon, evaluated at ϵ=−1/n\epsilon=-1/n, gives

θ^−i≈θ^−H−1∇R−i(θ^)=θ^+1nH−1∇L(zi;θ^).\hat{\theta}_{-i} \approx \hat{\theta} - H^{-1}\nabla R_{-i}(\hat{\theta}) = \hat{\theta} + \frac{1}{n}H^{-1}\nabla L(z_i;\hat{\theta}).

In the approximation, removal displaces the parameters along the example gradient after preconditioning by the inverse Hessian. At a positive-definite optimum, gradient components along eigenvectors with small eigenvalues are amplified more.

The Hessian deserves an intuition, because it tends to appear as an opaque matrix. The Hessian describes curvature: how quickly the gradient changes as you move through parameter space. Along a Hessian eigenvector, the displacement needed to offset an added gradient component scales inversely with the corresponding positive eigenvalue. Small positive eigenvalues permit larger displacements for the same gradient component. Multiplying by H−1H^{-1} is therefore a way of rescaling each gradient direction by how "stiff" the loss surface is there. In flat directions, the example's gradient has a lot of leverage. In stiff directions, it has little.

Now approximate the change in test loss:

Δi≈∇Ltest(θ^)⊤(θ^−i−θ^)≈1n∇Ltest(θ^)⊤H−1∇L(zi;θ^).\Delta_i \approx \nabla L_{\text{test}}(\hat{\theta})^\top \left( \hat{\theta}_{-i}-\hat{\theta} \right) \approx \frac{1}{n} \nabla L_{\text{test}}(\hat{\theta})^\top H^{-1} \nabla L(z_i;\hat{\theta}).

The upweighting score differentiates the test loss along this stationary branch at ϵ=0\epsilon=0, using the chain-rule construction from Koh and Liang (2017), section 2.1.

Iup(zi,ztest)=−∇Ltest(θ^)⊤H−1∇L(zi;θ^).I_{\text{up}}(z_i,z_{\text{test}}) = - \nabla L_{\text{test}}(\hat{\theta})^\top H^{-1} \nabla L(z_i;\hat{\theta}).

So

Δi≈−1nIup(zi,ztest).\Delta_i \approx -\frac{1}{n}I_{\text{up}}(z_i,z_{\text{test}}).

A positive IupI_{\text{up}} predicts higher test loss under a sufficiently small upweighting of example ii. A negative value predicts lower test loss. The first-order removal estimate flips these signs. A finite deletion can move far enough that its direct refit has a different sign, even in a smooth convex example.

The reason this sign convention is so treacherous is that two natural questions point in opposite directions. "What happens to test loss if I remove this example?" and "What happens to test loss if I upweight this example?" point in opposite directions to first order. The size of the weight change is 1/n1/n for removal from the objective above, so the derivative and estimated removal effect also differ by that factor. A table that lists "influence" without saying whether it is upweighting influence or leave-one-out effect is ambiguous to a reader who cannot see the code. The safest practice is to report the quantity you care about, state whether positive means helpful or harmful, and check the sign against a tiny worked case like the one later in this chapter.

The derivative assumes a smooth local branch near a stationary fit and a nonsingular Hessian there. Using it for deletion also assumes the local expansion stays accurate over the finite change. A smooth convex objective with a well-conditioned Hessian is a favorable setting. A nonconvex objective can have a suitable local minimum, but an SGD checkpoint may be far from stationary or have poorly conditioned curvature.

Practical approximations

Materializing a dense Hessian inverse is usually impractical for large models. For a model with pp parameters, a dense Hessian has p2p^2 entries. Practical methods avoid materializing it:

  • Damping: replace HH with H+δIH+\delta I, where δ\delta is a small positive scalar. For positive semidefinite HH, positive damping can improve conditioning. For indefinite HH, check the shifted spectrum before drawing that conclusion.
  • Hessian-vector products: use automatic differentiation to compute HvHv without forming HH, then use an iterative linear solver. Use standard conjugate gradient for a fixed symmetric positive-definite system.
  • Checkpoint gradients: TracInCP estimates influence using gradient dot products evaluated at saved model checkpoints.
  • Random projections: project gradients into a lower-dimensional space before estimating influence. This is the strategy behind TRAK and related scalable methods.
  • Model ensembles: train many models on different subsets and fit a surrogate from data inclusion to outputs. This is the datamodels approach.
  • Retrieval and similarity: use embeddings, BM25, or exact matching to locate training examples that resemble the output. Use these matches to choose items for closer inspection.

Adding δI\delta I shifts every eigenvalue by δ\delta. With an indefinite Hessian, a small shift can bring a negative eigenvalue closer to zero, making the inverse more sensitive. A shift larger than the magnitude of the most negative eigenvalue makes the matrix positive definite. Damping changes the inverse used by the estimator, and its signed dot products may increase or decrease in magnitude or change rank.

When the operator is symmetric positive definite, conjugate gradient approximates the solution of Hv=∇LtestH v = \nabla L_{\text{test}} with one operator application per ordinary iteration. Automatic differentiation can compute each Hessian-vector product without storing the dense Hessian. A full-risk product may still require accumulating contributions from many batches. Keep the checkpoint, damping, and data defining the operator fixed across iterations, including when using a fixed subset to approximate the full-risk curvature. Changing the sampled batch can change the operator even when every batch Hessian is positive definite. When reporting a solve cost, specify the batches, differentiation implementation, operator conditioning, and residual tolerance.

TracInCP uses saved model parameters from the training trajectory. At each checkpoint, it computes the training-example and test-example loss gradients, takes their dot product, and weights it by the learning rate for the interval ending at that checkpoint. The sum approximates the training example’s contribution to reducing the test loss along the trajectory. In the original derivation, each example is visited once per interval and the learning rate is constant within the interval. The checkpoint approximation can also serve as a heuristic when those conditions fail. It uses first derivatives. Pruthi et al. (2020), section 3.3

TRAK projects model-output gradients into a smaller space before using them in its kernel calculation. With a suitable projection dimension, the sketch approximately preserves gradient inner products with high probability. Approximation error can change the order of scores that are close together. Park et al. (2023), section 3

A datamodel uses predictions from models trained on many subsets of a fixed dataset. It fits a surrogate that predicts the model’s output on a chosen target using only which examples the subset contains. You can use it to estimate the effect of adding a candidate from that fixed dataset to a subset or removing one from it. Accuracy depends on which subsets were sampled, how many fits were available, and the choice of surrogate. Ilyas et al. (2022), sections 2 and 3

Retrieval scores similarity. Given a model output, retrieve the most similar training documents and use the matches to prioritize inspection. An influence method estimates how a specified change to the training data affects a target. A causal attribution claim needs evidence from a training-data intervention.

Each approximation answers a slightly different question. Influence functions estimate a local parameter effect. TracIn estimates a path-dependent gradient alignment. Datamodels use many trained models to predict outcomes under different choices of training examples. Retrieval estimates similarity. Name the method and target in the report.

Variants and tradeoffs

MethodWhat it estimatesMain costStrengthsImportant limits
Influence functionsLocal effect of upweighting an example on a targetHessian-vector productsGrounded in a clear counterfactualRequires suitable local curvature near a stationary fit; finite refits can disagree
TracInGradient alignment across training checkpointsCheckpoint storage and gradient computationUses training trajectory; no HessianPath-dependent; sensitive to checkpoint choice
DatamodelsPredicted effect of changing which examples from a fixed dataset are included in trainingMany trained modelsCan score subsets that were not among the surrogate’s training inputsExpensive, and the surrogate’s accuracy can vary across interventions
TRAKScalable approximation to influenceRandom projections and trained modelsDesigned for large modelsApproximate; assumptions about model and target
Data ShapleyFair credit allocation among training examplesExponential exact cost; sampling approximationsAxiomatic fairness propertiesUtility function choice changes the answer
Similarity searchNearest training examples by embedding or lexical matchBuilding and querying an indexRetrieves candidates for inspectionMeasures similarity
Ablation and retrainingTarget change under the specified data interventionSeparate refits, which can be costlyCompare fits under the same training protocolRepeat stochastic fits to estimate an average effect
Memorization and extraction testsWhether an output reproduces training textPrompt generation and matchingDirect evidence of overlapDoes not measure general influence

Use the question to choose a method. Similarity search can give you candidates to inspect. A controlled ablation can measure what changes under a specified intervention.

Two rows deserve special comment because they are often confused. Data Shapley is appealing because it comes with fairness axioms: it credits examples according to their marginal contribution to a chosen utility function, and it satisfies properties like symmetry and additivity. The catch is that the utility function is a modeling choice. Two teams can run Data Shapley on the same corpus and get different rankings because they defined "utility" differently, and neither is wrong. A Shapley attribution is always an attribution with respect to a stated utility, not an attribution in the abstract.

Memorization tests ask whether a model can reproduce training text, for example when prompted with a prefix. Use the resulting match to report overlap. To measure an effect on wider behavior, choose a target for that behavior and run an intervention. A training example can affect a target without being memorized verbatim.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy