· Xiaojing Yang · Explainability and Responsible AI · 4 min read
中文Instance-Level Attribution: Gradient Similarity, Influence Functions, and TracIn
A practical comparison of instance-level attribution methods for NLP: gradient similarity, influence functions, and TracIn, including assumptions and limitations.
Core idea
Instance-level attribution is useful for diagnosis, but gradient similarity, influence functions, and TracIn estimate different notions of influence. They should not be collapsed into one idea.
This note is part of my series Training Data Attribution for NLP and LLM Research. The series is written as both a research notebook and an interview preparation path: each article should help me explain the idea clearly, connect it to my thesis, and identify what would become future PhD work.
Guiding question: Which training examples are most related to one prediction or evaluation behaviour?

Intuition
Gradient similarity asks whether two examples would push parameters in similar directions. Influence functions approximate what would happen if a training example were upweighted. TracIn accumulates gradient alignment over checkpoints, avoiding one heavy inverse-Hessian computation but depending on saved training states.
In NLP and LLM research, this matters because model behaviour is deeply shaped by data mixture. A model may be fluent because of broad web text, domain-accurate because of specialised documents, safer because of curated instruction data, or biased because of repeated patterns in a subset of the corpus. Training-data attribution gives us language for asking these questions systematically instead of only saying “the data matters”.
Formal lens
Gradient similarity often uses cos(grad_theta L(z_train), grad_theta L(z_test)). Influence functions approximate the effect of upweighting z_train on test loss using -grad L_test^T H^{-1} grad L_train. TracIn sums gradient inner products across checkpoints, usually weighted by learning rate.
The important discipline is to define the attribution setup before interpreting the score:
| Design choice | Question to answer |
|---|---|
| Attribution unit | What receives credit: source, group, document, example, or token? |
| Utility function | Which behaviour is being explained: quality, terminology, style, factuality, or safety? |
| Intervention | Are we adding, deleting, reweighting, correcting, or retraining? |
| Estimator | Is the score exact, sampled, gradient-based, surrogate-based, or heuristic? |
| Uncertainty | How stable is the score across seeds, samples, metrics, and evaluation sets? |
NLP / LLM example
For an MT error involving a petroleum term, gradient-based retrieval may surface training sentence pairs with similar terminology or syntactic patterns. This is helpful for error analysis, but it still needs validation: retrieved examples may be correlated with the error without being the cause of it.
This is why I do not want to treat attribution as a generic interpretability topic. For my profile, the natural connection is multilingual and domain-specific NLP: low-resource settings, technical terminology, written-standard variation, and evaluation beyond one headline metric.
Connection to my thesis
In my thesis narrative, training-data attribution is useful because it turns a vague data question into an experimental design:
- define interpretable data units;
- define the model behaviour to explain;
- compare controlled data coalitions or interventions;
- estimate contribution;
- report uncertainty and limitations;
- decide what evidence is strong enough to support a causal-style claim.
That structure helps me avoid overclaiming. A score is not automatically a causal explanation. It is a measurement produced by a specific setup.
What I have done, understand, and would extend
| Level | Status |
|---|---|
| Already completed / thesis-ready | Group-level attribution, coalition thinking, metric-based utilities, cautious interpretation, random baselines, bootstrap-style reliability checks. |
| I understand but may not fully implement yet | Instance-level gradient attribution, influence functions, TracIn, Monte Carlo Shapley, surrogate/datamodel approximations. |
| Strong PhD extension | Hierarchical attribution, intervention-based validation, factuality/style-specific utilities, scalable attribution for LLM data mixtures. |
Interview answer
I would distinguish these methods clearly. Gradient similarity is simpler and cheaper, influence functions are more causal in spirit but depend on strong approximations, and TracIn is a checkpoint-based practical alternative. For my current work, instance-level methods are a diagnostic extension beyond group-level attribution.
References and reading path
- Lloyd Shapley, A Value for n-Person Games.
- Ghorbani and Zou, Data Shapley: Equitable Valuation of Data for Machine Learning.
- Koh and Liang, Understanding Black-box Predictions via Influence Functions.
- Pruthi et al., Estimating Training Data Influence by Tracing Gradient Descent.
- Ilyas et al., Datamodels: Predicting Predictions from Training Data.
- Rei et al., COMET: A Neural Framework for MT Evaluation.