Marginal

Data Attribution

Which training data made a model behave this way? Leave-one-out and Shapley attribution, influence functions and their effect on test loss, Bayesian influence functions, and unrolling training.

11 lessons in 1 unit · free with an account

Start your free trialThis course stays free after the trial.
What you'll learn

11 lessons, one small step at a time

Each lesson states its goal, then works up to it in short steps with practice after each. A placement test at the start skips what you already know.

Data Attribution

11 lessons
  1. Leave-one-out attributionCompute leave-one-out attributions in a simple model, and explain why they miss redundant examples and are costly and noisy.
  2. Data Shapley valuesCompute data Shapley values from the scores of models trained on subsets, use their efficiency property, and explain how they are approximated.
  3. Attribution as causationTreat data attribution as a causal question, recognize overdetermination and non-transitivity, and state the common target every attribution method estimates.
  4. Influence functionsEstimate the effect of removing a training example with the influence function, derive the formula, and explain why it is fragile for deep networks.
  5. LeverageCompute exact leave-one-out in least squares from the influence estimate and the leverage, and judge when the estimate can be trusted.
  6. Influence in deep networksExplain the three repairs that make influence functions usable for trained networks, what the repaired formula measures, and where it still breaks.
  7. Influence on test lossCompute the influence of a training example on a test loss, read its sign, and explain how the computation scales to large language models.
  8. Bayesian influence functionsCompute a Bayesian influence function as a covariance across posterior samples, and explain why it stays defined for singular models.
  9. Bayesian and classical influenceCompute a susceptibility as a covariance, localize the posterior around a checkpoint, and recover the classical influence function as the leading term.
  10. Unrolling trainingCompute how a training example's nudge decays over later steps, explain why the timing of an example matters, and estimate influence with TracIn.
  11. Unrolling in practiceTrace an example's effect through every training step, compute the natural damping of the SOURCE filter, and count the memory that exact metagradients need.
Sample lesson

Leave-one-out attribution

Goal: Compute leave-one-out attributions in a simple model, and explain why they miss redundant examples and are costly and noisy.

Which training examples are responsible for what a model does? Data attribution asks this counterfactual question, and the most direct answer is to remove an example, retrain and see what changes.

We will remove, retrain and compare, find the blind spot of redundancy, and finish with cost and noise.

Step 1: Remove, retrain, compare

The leave-one-out (LOO) effect of a training example is the change in a model's prediction, or loss, when the model is retrained without it. Take a model that predicts the mean of its n training targets. Removing a target z changes the mean from m to (nm − z) ÷ (n − 1), a change of

Δ = (m − z) ÷ (n − 1)

An example far from the mean has a large effect, and one equal to the mean has none. For targets (2, 4, 9) with mean 5, removing 9 lowers the prediction by 4 ÷ 2 = 2.

Step 2: Redundancy

LOO asks what changes if one example disappears, and that can miss examples that matter. If two training documents both teach a model the same fact, removing either one leaves the other, so the model still knows the fact and each document gets almost no credit, even though together they are the whole reason the model knows it. LOO cannot split credit among redundant examples; the next lesson's Shapley values are designed to.

Step 3: Cost and noise

Exact LOO needs one full retraining per training example: billions of retrainings for a large language model, which is impossible. Training randomness adds a second problem: retraining with a different random seed or data order changes the model even with nothing removed, so a small LOO effect can be swamped by run-to-run noise. Still, the question LOO asks is the right one for safety: which data produced an unwanted behavior, so it can be found and filtered.

In the app, each step ends with practice questions, new ones every time, and the lesson comes back later in spaced reviews.

Start Data Attribution

Lessons that need something you haven't learned yet bring it in first, from any course.

Start your free trialThis course stays free after the trial.