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.
| Component | Role | Practical cost |
|---|---|---|
| Training gradient | Direction one example pushes the parameters | One backward pass per example |
| Test gradient | Sensitivity of the test loss | One backward pass per query |
| Inverse Hessian | Corrects for loss curvature | Dominant cost, must be approximated |
| Damping term | Stabilizes inversion of a near-singular Hessian | Adds a hyperparameter |
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.
| Method | Key idea | Best suited for |
|---|---|---|
| LiSSA | Stochastic iterative estimate of inverse-Hessian-vector products | Medium-size models |
| Conjugate gradient | Solves the linear system iteratively | Convex or small models |
| EK-FAC | Kronecker-factored curvature approximation | Large language models |
| TracIn | Sums gradient dot products over checkpoints | When training checkpoints exist |
| TRAK | Random projections of gradients with a linearized model | Large datasets and many queries |
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.
| Method | Explains through | Typical question answered |
|---|---|---|
| Influence function | Training examples | Which data made the model predict this |
| Shapley value attribution | Input features | Which features drove this prediction |
| Data Shapley | Training examples | What is each example worth to overall accuracy |
| Prototype methods | Learned representative examples | Which typical case does this resemble |
| Counterfactual explanation | Changed inputs | What change would flip the outcome |
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.
| Limitation | Effect | Mitigation |
|---|---|---|
| Non-convex loss | Hessian may be indefinite | Add damping, use Gauss-Newton curvature |
| Training not converged | First-order assumption breaks | Use checkpoint-based methods |
| Group effects ignored | Misses joint influence of similar points | Use group influence estimates |
| High compute cost | Slow for many test queries | Cache projected gradients |
| Outlier dominance | Rankings favor high-loss points | Normalize gradients before scoring |
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.