Influence function

Also known as: influence functions

On this page 7

An influence function is a tool from robust statistics that estimates how a model’s parameters or predictions would change if a single training example were removed or upweighted, without actually retraining the model. In explainable AI, influence functions answer a question that feature attribution cannot: which training data caused this prediction.

The idea dates back to the work of Frank Hampel and the Cook’s distance diagnostics of the 1970s, and it was adapted to modern machine learning in 2017 by Pang Wei Koh and Percy Liang. Influence functions are now a core method of training data attribution, used for debugging datasets, finding mislabeled examples and explaining model behavior through example-based explanations.

How influence functions approximate retraining

Influence functions replace an expensive experiment, leave-one-out retraining, with a first-order Taylor approximation around the trained parameters. Instead of retraining once per training point, the method asks how the optimal parameters would move if the loss of one example received an infinitesimally larger weight.

For a model with parameters θ trained to minimize empirical risk, the influence of upweighting a training point z on the parameters is -H⁻¹ ∇L(z, θ), where H is the Hessian of the training loss. The influence on the loss at a test point z_test is then -∇L(z_test, θ)ᵀ H⁻¹ ∇L(z, θ), a gradient similarity weighted by inverse curvature.

The sign carries meaning. A negative influence on test loss marks a helpful training example whose presence lowered the error, while a positive value marks a harmful example. The table below lists the main ingredients of the computation.

ComponentRolePractical cost
Training gradientDirection one example pushes the parametersOne backward pass per example
Test gradientSensitivity of the test lossOne backward pass per query
Inverse HessianCorrects for loss curvatureDominant cost, must be approximated
Damping termStabilizes inversion of a near-singular HessianAdds a hyperparameter
Components of the influence calculation

Approximations that make influence functions scale

Exact Hessian inversion is infeasible for networks with millions of parameters, because the Hessian grows with the square of the parameter count. Practical implementations therefore rely on approximations that trade accuracy for speed.

MethodKey ideaBest suited for
LiSSAStochastic iterative estimate of inverse-Hessian-vector productsMedium-size models
Conjugate gradientSolves the linear system iterativelyConvex or small models
EK-FACKronecker-factored curvature approximationLarge language models
TracInSums gradient dot products over checkpointsWhen training checkpoints exist
TRAKRandom projections of gradients with a linearized modelLarge datasets and many queries
Common influence approximation methods

Methods such as TracIn and TRAK are sometimes grouped with influence functions because they share the goal of training data attribution, even though they do not use the classical Hessian formula. Research on large language models has applied EK-FAC influence to models with tens of billions of parameters.

Influence functions among other explanation methods

Influence functions explain predictions through training data rather than through input features, which places them in a different family from SHAP, LIME or saliency maps. The comparison below shows how they relate to neighboring methods in explainable AI.

MethodExplains throughTypical question answered
Influence functionTraining examplesWhich data made the model predict this
Shapley value attributionInput featuresWhich features drove this prediction
Data ShapleyTraining examplesWhat is each example worth to overall accuracy
Prototype methodsLearned representative examplesWhich typical case does this resemble
Counterfactual explanationChanged inputsWhat change would flip the outcome
Influence functions compared with related methods

Unlike nearest-neighbor retrieval, which returns examples that merely look similar in embedding space, influence functions return examples that the learning process actually depended on. Two visually similar images can have very different influence scores.

Practical applications

Influence functions are most useful when the question concerns data quality and provenance rather than individual feature contributions. Common applications include the following.

  • Detecting mislabeled examples by ranking training points with high self-influence.
  • Tracing harmful outputs of language models back to the documents that encouraged them.
  • Auditing data poisoning, where a small number of crafted points have outsized effect.
  • Explaining a prediction to domain experts with concrete training cases.
  • Prioritizing data cleaning budgets toward the most influential records.

A typical workflow starts from a specific failure, such as a wrong prediction or an undesirable model output, and computes influence scores against the full training set or a candidate subset. Analysts then inspect the top-ranked helpful and harmful examples, look for shared patterns such as labeling errors, duplicated records or spurious artifacts, and decide whether to relabel, remove or reweight the data. Libraries such as Captum provide ready-made influence implementations for PyTorch models, which lowers the barrier to adoption.

Self-influence, the influence of a training example on its own loss, is a particularly cheap and effective signal. Examples with unusually high self-influence are hard for the model to fit from the rest of the data, which makes them strong candidates for label errors, outliers or rare subgroups that deserve human review.

Assumptions, limitations and reliability

The classical derivation assumes a strictly convex, twice-differentiable loss and parameters at the exact optimum. Deep networks violate both assumptions, because their losses are non-convex and training stops early, so influence estimates are approximations of uncertain fidelity.

Empirical studies have shown that influence estimates for deep models can correlate weakly with true leave-one-out retraining, particularly for large networks and for examples far from the decision boundary. The table summarizes the main failure modes.

LimitationEffectMitigation
Non-convex lossHessian may be indefiniteAdd damping, use Gauss-Newton curvature
Training not convergedFirst-order assumption breaksUse checkpoint-based methods
Group effects ignoredMisses joint influence of similar pointsUse group influence estimates
High compute costSlow for many test queriesCache projected gradients
Outlier dominanceRankings favor high-loss pointsNormalize gradients before scoring
Known limitations and mitigations

Because of these issues, practitioners treat influence scores as useful rankings for investigation rather than exact measurements, and they validate key findings by retraining on a modified dataset whenever the cost allows.

The simple explanation

A model learns from thousands or millions of examples. When it makes a decision, it is hard to know which of those examples shaped it. An influence function estimates the answer without training the model again.

Imagine a student who passed an exam. You want to know which practice problems helped most. Removing each problem and repeating the course would take forever. Instead, you estimate how much each problem shifted the student’s thinking. Influence functions do the same for a model and point to the training examples that mattered most.

How it is used in practice

A medical imaging team trains a classifier on about 40,000 chest X-ray images to flag possible pneumonia. During validation, a radiologist notices that the model confidently labels several healthy scans as positive.

The team computes influence scores with an EK-FAC approximation for each misclassified scan and inspects the top 50 training images for each one. Many of the most harmful images share a hospital-specific text marker in the corner and turn out to be mislabeled scans from a single source.

After relabeling about 300 images and cropping the markers, the team retrains the model. The false-positive rate on the validation set drops noticeably, and the influence analysis becomes part of the documentation that explains how the dataset was cleaned and audited.