Part 6 left us with a beautiful answer and an unpaid bill. The Shapley value repairs leave-one-out attribution when examples are redundant. It gives a point credit across every group of classmates it could have joined, so one useful example cannot hide behind a substitute. The repair comes with a definition that ranges over every subset of the training set. For our 60-student classroom, that means \(2^{60}\) coalitions. The theory resolves the fairness problem by creating a computation problem.
That debt matters because Shapley is a scoring rule with a fairness guarantee. It is the unique credit assignment satisfying equal treatment and zero credit for a useless contributor; its credits also add across tasks (Ghorbani and Zou 2019). It sits inside the datamodel view from part 6: one coefficient per training point, added to predict what a subset will do. If we want that coefficient at useful scale, we need a way around exhaustive enumeration.
This post tries two routes on the original logistic-regression classroom from part 1. The model still trains for 1,500 gradient-descent iterations on 60 points, and the gold-star query remains at \((0.35, -0.15)\). One route samples many possible classroom orderings after training. The other accumulates an estimate while the one ordinary training run is already happening. Both target the same per-point Shapley value. Their computational lives are entirely different.
What ground truth can mean here
A Shapley value is an average over orderings. An ordering, or permutation, is simply a list that places every training point once. Walk down one such list and add the points one at a time. For point \(i\), record its marginal contribution, the change in the gold-star query’s utility at the moment \(i\) joins the current coalition. Repeat across every possible ordering and average those changes. That average is the Shapley value.
Every possible ordering is still out of reach. The feasible baseline is Monte Carlo: sample random orderings, compute their marginal contributions, then average. The final answer is an estimate with sampling error. Throughout this post, “ground truth” means the estimate from 8,000 sampled permutations. It never means exact enumeration.
The ordering view explains how Shapley handles redundancy. Suppose a point arrives after another example has already taught the same feature. Its marginal contribution can be small because the coalition already has what it needs. In orderings where that substitute has not arrived, the point can receive substantial credit. Averaging over positions gives both examples credit in proportion to the situations where each one adds something. Leave-one-out sees only the full classroom, where both substitutes are present, so it misses that structure.
Sampling preserves this logic while replacing the impossible average with an empirical one. Each random ordering gives every point one observed marginal contribution. A point that changes roles across coalitions produces a variable sequence of observations, which raises its standard error. A point with a consistent role settles faster. The uncertainty is therefore part of the attribution result: it tells us how much the sampled coalition contexts still disagree about a point’s average credit.
The utility is negative test loss at the gold star. Under this convention, a positive score means the training point was helpful. This fixes the sign once for every figure below.
A Monte Carlo estimate only deserves to be a ruler after it has settled. We therefore compute it at budgets of 500, 1,000, 2,000, 4,000, and 8,000 permutations. At each budget, we also use a bootstrap, a resampling procedure that repeats the average using draws from the sampled permutations, to estimate a standard error for each point. The whiskers in Fig. 1 show those errors.
Prove the ruler has settled
FIG. 1 · CONVERGENCE BEFORE COMPARISON
Start at 500 sampled permutations and step through every budget. Each bar is one classroom point; its whisker is a bootstrap standard error. Spearman rank stability compares each ranking with the previous budget. The last comparison, 4,000 against 8,000 permutations, reaches 0.9852. The largest-budget estimate is stable enough to act as this post’s ruler, and its visible whiskers preserve the uncertainty that remains.
The first comparison is already strong at 0.9694. It then moves through 0.9671 and 0.9765 before reaching 0.9852. The small dip shows that an added batch can lower an individual diagnostic. The plateau across budgets and contracting standard errors provide the convergence evidence.
Spearman correlation is the right diagnostic for the use we make of this ruler. Later, we compare whether the in-run method ranks the classroom points in the same order. A stability check based on raw numeric distance would answer a stricter calibration question and could keep moving even after the ranking had settled. Here we need to know whether adding more sampled orderings still swaps the students near the top and bottom of the list. The final stability value says those swaps have become rare across the complete ranking.
That sequence also prevents a tempting mistake. If we had drawn only the 8,000-permutation result, its bars would look authoritative because the chart is clean. The budget controls expose the estimate’s history. Measured stability earns the ruler its authority.
The spot check tests the shortcut at coalition positions spread across the walk. It asks whether refinement from the preceding coalition lands at nearly the same query utility as a fresh fit. The maximum gap is small relative to the Shapley values visible in Fig. 1. The measured error bound covers the sampled checks, leaving untested positions outside its guarantee. It also catches the special one-label case that would otherwise behave badly.
Warm starts also preserve the sequential meaning of a permutation. The model for one prefix becomes the starting point after the next student arrives. Computation falls because nearby coalitions differ by one point. The target quantity remains the average marginal utility along the sampled orderings; the disclosed approximation lies in how each coalition model is fitted.
Read the estimate from one run
Monte Carlo pays after training: sample an ordering, refine 60 coalition models along it, then do the same for thousands more orderings. In-Run Data Shapley changes when the accounting happens. It follows the ordinary optimizer and assigns each update’s effect on the query back to the training points that produced the update (Wang et al. 2025). The result grows during the same 1,500 iterations used to train the classroom model.
A Taylor expansion approximates how the query loss changes near the current weights. The first-order term follows the local slope. The second-order term corrects for local curvature. Their per-point shares enter a running total before the optimizer moves on.
The local approximation is a Taylor expansion, a polynomial that estimates a function near the current weights from its slope and curvature. At each optimizer step, the method uses first-order and second-order terms to allocate the query’s predicted utility change across points. Adding those allocations over the run produces one score per example. The generated replay verifies that its weights match the ordinary classroom trainer and that the allocated total satisfies the efficiency identity to the recorded precision.
The two correction terms have different jobs. The first-order term asks how the query loss would move if the point’s gradient nudged the weights along a straight local slope. Training crosses a curved loss surface, so the second-order term adjusts that prediction using local curvature. Each update contributes a small signed amount to every point’s running account. The sum across updates is the final in-run score.
This accounting is tied to the realized optimization path. Change the learning rate or the model initialization, and the local terms can change. That dependence fits the question here: what credit does this specific run assign while learning the gold-star query? A distributional claim across possible runs would require repeating the experiment and describing how the scores vary.
Fig. 2 lets the accounting unfold. Choose a point to track, then step through checkpoints or play the run. The ranked strip on the right contains all 60 running estimates. Per-checkpoint model weights are absent from the JSON, so the classroom panel locates the tracked student and leaves the decision boundary fixed. At the final checkpoint, the comparison toggle adds the Monte Carlo values and their uncertainty as reference marks.
FIG. 2 · SIXTY ESTIMATES ACCUMULATE DURING ONE RUN
Play, pause, step, or use the checkpoint slider. The selected classroom point stays linked to its trajectory while all 60 bars reorder. At iteration 1,500, “Compare to ground truth” overlays the final Monte Carlo estimate and bootstrap uncertainty for every point. The overlay is a preview of the direct comparison below; this figure’s claim is that the scores were accumulated during one training run.
Early in the run, some trajectories grow quickly while others remain close to zero. That shape reflects the optimizer’s path. The query is most sensitive to certain updates when the boundary is still moving, and later updates refine a model already near its fitted solution. In-run attribution keeps this temporal record instead of reconstructing thousands of alternate datasets afterward.
Compare two noisy answers
The final comparison uses the same 60 points on both axes. Horizontal position is the in-run estimate. Vertical position is the 8,000-permutation Monte Carlo estimate. The identity line marks equal numeric values; each vertical whisker carries the Monte Carlo standard error from Fig. 1. Those whiskers matter because a dot missing the line by a small amount may still be consistent with the baseline’s own sampling variation.
FIG. 3 · IN-RUN AGAINST MONTE CARLO, WITH ERROR BARS
The measured Spearman rank correlation is 0.9847. Hover or focus a dot to locate the same point in the classroom; tapping locks the link. The high correlation says the two estimators put the points in almost the same order on this query. Different axis scales in the raw values remain visible, so calibration remains a separate question.
The correlation is 0.98466 before rounding for display. That is strong evidence for rank agreement in this classroom. It is narrower than a claim of equality. The in-run magnitudes spread farther from zero than the Monte Carlo magnitudes, so summing the raw in-run scores as calibrated utilities would require another check. The experiment supports ranking points for this model and query.
Rank agreement has a concrete consequence. If a debugging tool asks for the most helpful or most harmful training examples, the two methods will return nearly the same ordering here. A valuation system that pays in proportion to the raw score asks a different question. The identity line and the unequal spreads warn that the in-run values need calibration before they can be treated as interchangeable shares.
The linked classroom panel checks whether disagreement clusters in a recognizable region. Influence depends on the gold-star query and the fitted parameters, so geometric distance alone cannot rule out a point far from the boundary. Hovering a surprising dot forces the abstract comparison back onto the same dataset used throughout the series.
Both sides are estimates for different reasons. Monte Carlo averages a finite set of sampled orderings. In-run uses a second-order local approximation along one optimizer trajectory. Their agreement is informative because the errors arise from different procedures. It remains evidence from one instrumented problem.
Pay the bill in training runs
The build script times both procedures in a shared unit: one ordinary 1,500-iteration training run. Monte Carlo to the accepted budget costs 9,305.51 training-run equivalents on the build machine. The in-run replay, including its accumulation work, costs 4.67. The second number exceeds one because this teaching implementation records and checks per-point terms in an unoptimized NumPy loop. It still avoids the thousands of coalition refinements that dominate Monte Carlo.
FIG. 4 · THE MEASURED BILL
The two colored rows are toy measurements from the generated JSON, shown on a logarithmic axis so both remain legible. Reveal the grayscale literature row to see the paper’s GPT-2-scale claim (Wang et al. 2025). Its text-only treatment reflects the scope of this classroom measurement, which stops before LLM scale.
The cost gap is the method’s practical argument. Monte Carlo creates 480,000 refined coalition positions to establish a trustworthy baseline. The in-run method attaches accounting to the single optimization trajectory we already wanted. Wang and colleagues report that this accounting adds negligible overhead at GPT-2 scale (Wang et al. 2025). That published statement is evidence from their system. Fig. 4 keeps it visually separate from this build machine’s measured multiples.
The logarithmic axis prevents the cheaper row from collapsing into a hairline. It also demands care: equal visual distances represent multiplicative changes. The printed labels carry the exact comparison, while bar length gives the order of magnitude. Both colored rows come from the same timing record and share the same training-run unit.
The toy’s 4.67 multiple belongs to this implementation, which records all per-point terms in a teaching-oriented loop and runs internal checks. The paper’s system is built for a different workload. The defensible cross-scale claim is structural: in-run accounting follows one training trajectory, while permutation Monte Carlo repeatedly fits coalition models.
What this classroom establishes
The result fits into part 6’s map as a linear datamodel obtained from a trajectory. On the original 60-point logistic classroom, an in-run second-order estimate reaches 0.98466 Spearman agreement with a Monte Carlo Data Shapley baseline whose rank stability reaches 0.98516 at the final budget transition. It gets that ranking from one training run and avoids sampled coalition walks.
The boundary of the claim is equally concrete. The Monte Carlo ruler retains bootstrap error. Its coalition training uses a verified warm-start shortcut. The in-run calculation approximates each step with local Taylor terms. We studied one seeded run on a small convex model and one query. Other architectures and language-model training regimes remain outside this validation.
That boundary sets up part 9. The bake-off changes the model while holding the evaluation subsets fixed. Several attribution scorers then predict the same retrainings. Shapley without exhaustive combinatorics solves one bill. Choosing among attribution methods still requires a ruler tied to the decision we want to make.
Further reading
The baseline and the single-run method
- Ghorbani and Zou, “Data Shapley: Equitable Valuation of Data for Machine Learning” (Ghorbani and Zou 2019), develops the fairness framing and the permutation-sampling baseline.
- Wang, Mittal, Song, and Jia, “Data Shapley in One Training Run” (Wang et al. 2025), develops the Taylor-accumulation method used as this post’s spine.
References
Reproducibility. Every toy number comes from scripts/influence-data/08_inrun_shapley.py with seed 7. The script uses at most 8,000 Monte Carlo permutations and warm-start refinement length 450. It records the in-run estimates at checkpoints across 1,500 iterations and uses a seeded bootstrap. The generated shapley.json supplies every estimate, error bar, diagnostic, and timing multiple shown here.