Interpretability, attribution, and explanation audits · Interpretability, explanations, and model-mechanism analysis · EXP010 · Algorithm
TRAK: tracing with the randomly projected after kernel
Estimate training-data attribution with projected gradient features, a linearized kernel calculation, task-specific weights, and aggregation over fitted models.
In CodeSplash
Documented in the Academy only. There's no Set up button.
- Availability
- Explained here
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Estimate training-data attribution with projected gradient features, a linearized kernel calculation, task-specific weights, and aggregation over fitted models.
Question / hypotheses
Can a tractable attribution score predict how a target behavior changes across training-data subsets? This is a data-attribution estimand rather than feature importance.
Architecture / computational structure
A task-specific model-output function supplies parameter gradients. Random projection compresses them into features. A regularized feature-Gram solve combines target/training features and loss-related weights; multiple trained models can be aggregated. Task adapters determine the output and weighting definitions.
Assumptions
The output function must match the training task and differentiation convention. Projection dimension, conditioning and ensemble variation affect approximation quality. Gradient linearization and subset prediction are approximations, not exact retraining identities for arbitrary deep systems.
Formula / computational definition
Parameters and notation
The formula is a single-model schematic kernel calculation. Φ contains projected training gradients; Q is a diagonal task-specific weighting, such as correct-label error probability for a classification setup. Choices include projection dimension/seed, damping λ, gradient normalization, training-model ensemble, and target output. Here z is an example, theta fitted parameters, f a task-specific scalar model output, P a parameter-to-projection matrix, Phi the matrix with projected training-feature rows, I the identity matrix, and tau the vector of training-example scores for a query.
Fitting, fine-tuning, and adaptation
Recompute the feature database after predictor adaptation. Preserve dataset identifiers and loss conventions. Model ensembles used for attribution have training cost; projected features reduce storage but do not make full gradient extraction free.
How to use and calibrate
Evaluate attribution against controlled subset-retraining experiments, not only visually plausible top examples. Report projection/model-count sensitivity, matrix conditioning, memory, and the exact task adapter. Use the author implementation for the complete estimator.
Example application
Attribute a target classifier score to training examples and assess whether the ranking predicts score changes after removing a selected subset.
Interpretation / pitfalls
Watch out
The displayed kernel algebra is only part of TRAK. Different output functions and averaging conventions can yield different estimands. Large attribution does not establish dataset ownership, memorization, or a causal real-world mechanism.
Python and R code examples
Scope: Supplied projected features and classification-style Q weights illustrate one regularized kernel scoring component; no model ensemble, gradient extraction or complete TRAK pipeline. Python: NumPy; R: base R.
Validation: Python executed successfully on the supplied fixture; R reviewed but unexecuted. Full implementations and supported operation details are provided in the linked primary/official sources.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Supplied projected features and classification-style Q weights illustrate one regularized kernel scoring component; no model ensemble, gradient extraction or complete TRAK pipeline. Python: NumPy; R: base R. · needs numpy
import numpy as np
Phi=np.array([[1.,0.],[0.,1.],[1.,1.]]);target=np.array([.5,1.]);q=np.array([.1,.2,.4]);lam=.1
score=target@np.linalg.solve(Phi.T@Phi+lam*np.eye(2),Phi.T)*q
assert score.shape==(3,) and np.isfinite(score).all();print(score)
Component demo, not a trained model — Supplied projected features and classification-style Q weights illustrate one regularized kernel scoring component; no model ensemble, gradient extraction or complete TRAK pipeline. Python: NumPy; R: base R.
Phi<-rbind(c(1,0),c(0,1),c(1,1));target<-c(.5,1);q<-c(.1,.2,.4);lam<-.1
score<-drop(target%*%solve(crossprod(Phi)+lam*diag(2),t(Phi)))*q
stopifnot(length(score)==3,all(is.finite(score)));print(score)
Sources
- Source 1proceedings.mlr.press
- Source 2github.com
From the CodeSplash reference, entry EXP010.