HyperAIHyperAI

Command Palette

Search for a command to run...

DATA SHAPLEY EN UNE SEULE SESSION D'ENTRAÎNEMENT

Jiachen T. Wang Prateek Mittal Dawn Song Ruoxi Jia

Résumé

Data Shapley offre un cadre formel pour attribuer la contribution des données dans les contextes d'apprentissage automatique. Cependant, la notion traditionnelle de Data Shapley requiert le réentraînement de modèles sur divers sous-ensembles de données, ce qui devient computationnellement infaisable pour les modèles à grande échelle. De plus, cette définition basée sur le réentraînement ne permet pas d'évaluer la contribution des données pour une session d'entraînement spécifique, ce qui est souvent d'intérêt en pratique. Cet article introduit un nouveau concept, In-Run Data Shapley, qui élimine le besoin de réentraînement et est spécifiquement conçu pour évaluer la contribution des données pour un modèle d'intérêt particulier. In-Run Data Shapley calcule la valeur de Shapley pour chaque itération de mise à jour du gradient et accumule ces valeurs tout au long du processus d'entraînement. Nous présentons plusieurs techniques permettant de faire évoluer efficacement In-Run Data Shapley à la taille des modèles de fondation. Dans son implémentation la plus optimisée, notre méthode ajoute une surcharge d'exécution négligeable par rapport à l'entraînement standard d'un modèle. Cette amélioration spectaculaire de l'efficacité rend possible l'attribution de données pour l'étape de pré-entraînement des modèles de fondation. Nous présentons plusieurs études de cas offrant un regard nouveau sur la contribution des données de pré-entraînement et discutons leurs implications en matière de droit d'auteur dans l'IA générative et de curation des données de pré-entraînement.

One-sentence Summary

Princeton University, UC Berkeley, and Virginia Tech propose In-Run Data Shapley, a method that computes Shapley values at each gradient update iteration and accumulates them throughout a single training run, eliminating the need for model retraining with negligible runtime overhead to enable data attribution at foundation model pretraining scale, with case studies offering insights into copyright implications for generative AI and pretraining data curation.

Key Contributions

  • The paper introduces In-Run Data Shapley, which computes Shapley values at each gradient update iteration and accumulates them across a specific training run, removing the need to retrain models on many data subsets.
  • Efficient ghost-family computation techniques scale In-Run Data Shapley to foundation model pretraining, and the most optimized implementation adds negligible runtime overhead compared to standard model training.
  • Experiments and case studies demonstrate attribution of pretraining data contribution, yielding insights relevant to copyright in generative AI and pretraining data curation.

Introduction

  • The authors focus on data attribution for large language models and other foundation models, where knowing each training source’s influence matters for fair compensation, copyright analysis, regulatory risk, and filtering low-quality or harmful data.

  • Existing Shapley value frameworks offer a theoretically fair basis for attribution, but prior methods usually require repeated retraining, are computationally infeasible at foundation model scale, and score data for a general training algorithm rather than the actual model being trained.

  • The authors introduce In-Run Data Shapley, which estimates Shapley contributions during training by approximating one-step model changes with Taylor expansions and computing the needed gradient dot products or gradient-Hessian-gradient interactions efficiently, making attribution possible for models such as GPT-2 and Pythia-410M.

Dataset

  • The authors use a Pile subset as the main training corpus in the case study. They uniformly sample about 10B tokens from the Pile, train a GPT2 model on that subset, and score training points against the Pile validation set. They then remove all negatively valued corpora and retrain on the cleaned subset. The cleaned data reaches a test loss of 3.75 with about 25% fewer training iterations, and about 16% of the subset receives negative second order attribution values. This processing treats attribution scores as a filtering signal for low quality or harmful training examples.

  • The authors also reference an Original Wikipedia corpus. It appears to contain short factual or encyclopedic prose passages, with the provided example being a biographical or historical snippet. The excerpt does not report the corpus size, exact filtering rules, schema, training split, or mixture ratio.

  • The authors include a Synthetic "Similar topic" corpus nested under the Original Wikipedia corpus. It contains topic-aligned synthetic text, including an instruction-answer style passage and short related domain snippets. The excerpt does not specify its total size, filtering process, metadata fields, or how it is mixed into training.

  • The excerpt does not describe a cropping strategy, metadata construction, or formal dataset split for the non-Pile corpora. Quantitative usage details, including scale, filtering, and retraining effects, are provided only for the Pile experiment.

Method

The authors introduce a data attribution framework called In-Run Data Shapley. The central design principle is to avoid retraining the model on exponentially many subsets of the training data. Instead, the method treats a single training run as a sequence of gradient update steps and attributes the loss change at each step to the data points that participated in that step. This creates a “divide and conquer” framework: the original high-level problem of valuing a training set over the full training process is decomposed into many small local attribution problems, one for each mini-batch update. The final score for a data point is the sum of its contributions over all iterations in which it is sampled.

The core idea begins with the usual stochastic training setup. A deep learning model with parameters wtw_twt​ is trained on a dataset Dtr={zi}i=1N\mathcal{D}_{\mathrm{tr}} = \{z_i\}_{i=1}^NDtr​={zi​}i=1N​ by minimizing a training loss such as ∑iℓ(w,zi)\sum_i \ell(w, z_i)∑i​ℓ(w,zi​). At iteration ttt, a mini-batch Bt⊆Dtr\mathcal{B}_t \subseteq \mathcal{D}_{\mathrm{tr}}Bt​⊆Dtr​ is sampled, and the parameters are updated by

wt+1:=wt−ηt∑z∈Bt∇ℓ(wt,z),w_{t+1} := w_t - \eta_t \sum_{z \in \mathcal{B}_t} \nabla \ell(w_t, z),wt+1​:=wt​−ηt​z∈Bt​∑​∇ℓ(wt​,z),

where ηt\eta_tηt​ is the learning rate. A full training run therefore produces a sequence of checkpoints {w0,w1,…,wT}\{w_0, w_1, \ldots, w_T\}{w0​,w1​,…,wT​}.

To measure the effect of a subset SSS on a single update, the authors define a local utility function. For a validation point z(val)z^{(\mathrm{val})}z(val), the utility at iteration ttt is the counterfactual change in validation loss if only SSS were used for the gradient update, instead of the full batch Bt\mathcal{B}_tBt​:

U(t)(S;z(val)):=ℓ(w~t+1(S),z(val))−ℓ(wt,z(val)),U^{(t)}(S; z^{(\mathrm{val})}) := \ell(\widetilde{w}_{t+1}(S), z^{(\mathrm{val})}) - \ell(w_t, z^{(\mathrm{val})}),U(t)(S;z(val)):=ℓ(wt+1​(S),z(val))−ℓ(wt​,z(val)),

where

w~t+1(S):=wt−ηt∑z∈S∇ℓ(wt,z).\widetilde{w}_{t+1}(S) := w_t - \eta_t \sum_{z \in S} \nabla \ell(w_t, z).wt+1​(S):=wt​−ηt​z∈S∑​∇ℓ(wt​,z).

This local utility is defined over the batch Bt\mathcal{B}_tBt​. It can be extended to the full training set by giving zero influence to points outside Bt\mathcal{B}_tBt​. The resulting per-iteration Shapley value captures only the immediate contribution of each sampled point to that gradient update. Because the batch sampling process is fixed during the training run, the utility function becomes deterministic for that iteration and can also encode other forms of training randomness, such as dropout, by conditioning on the realized state.

The method then aggregates these local utilities across the entire training run. The global utility function is defined as

U(S;z(val))=∑t=0T−1U(t)(S;z(val)).U(S; z^{(\mathrm{val})}) = \sum_{t=0}^{T-1} U^{(t)}(S; z^{(\mathrm{val})}).U(S;z(val))=t=0∑T−1​U(t)(S;z(val)).

This represents the cumulative validation-loss change caused by using the subset SSS across all updates, under the counterfactual assumption that the model follows the same checkpoint trajectory and batch realizations. Since Shapley values are linear with respect to the utility function, the global attribution is simply the sum of the local attributions:

ϕz(U)=∑t=0T−1ϕz(U(t)).\phi_z(U) = \sum_{t=0}^{T-1} \phi_z(U^{(t)}).ϕz​(U)=t=0∑T−1​ϕz​(U(t)).

Thus, the final In-Run Data Shapley score for a training point is its cumulative contribution across all gradient updates in which it appears. If the model is evaluated on a validation set D(val)\mathcal{D}^{(\mathrm{val})}D(val) rather than a single validation point, the authors leverage the same linearity property and compute the total attribution by summing the scores over all validation points.

A key part of the method is making the Shapley calculation tractable. Directly evaluating U(t)(S)U^{(t)}(S)U(t)(S) for all subsets of a mini-batch is infeasible. The authors therefore approximate the local utility with Taylor expansions around the current model parameters wtw_twt​. The first-order approximation is

U(1)(t)(S)=∇ℓ(wt,z(val))⋅(w~t+1(S)−wt).U_{(1)}^{(t)}(S) = \nabla \ell(w_t, z^{(\mathrm{val})}) \cdot \left( \widetilde{w}_{t+1}(S) - w_t \right).U(1)(t)​(S)=∇ℓ(wt​,z(val))⋅(wt+1​(S)−wt​).

Substituting the gradient update form gives

U(1)(t)(S)=−ηt∑z∈S∇ℓ(wt,z(val))⋅∇ℓ(wt,z).U_{(1)}^{(t)}(S) = -\eta_t \sum_{z \in S} \nabla \ell(w_t, z^{(\mathrm{val})}) \cdot \nabla \ell(w_t, z).U(1)(t)​(S)=−ηt​z∈S∑​∇ℓ(wt​,z(val))⋅∇ℓ(wt​,z).

This approximation is additive over the subset SSS, so it admits a closed-form Shapley value:

ϕz(U(1)(t))=−ηt∇ℓ(wt,z(val))⋅∇ℓ(wt,z).\phi_z(U_{(1)}^{(t)}) = -\eta_t \nabla \ell(w_t, z^{(\mathrm{val})}) \cdot \nabla \ell(w_t, z).ϕz​(U(1)(t)​)=−ηt​∇ℓ(wt​,z(val))⋅∇ℓ(wt​,z).

Accumulating over the training run yields the first-order In-Run Data Shapley estimator:

ϕz(U)≈∑t=0T−1ϕz(U(1)(t)).\phi_z(U) \approx \sum_{t=0}^{T-1} \phi_z(U_{(1)}^{(t)}).ϕz​(U)≈t=0∑T−1​ϕz​(U(1)(t)​).

In this formulation, a data point receives positive attribution when its gradient direction at the current checkpoint aligns with the gradient direction of the validation point. A negative attribution indicates that the training point pushed the model in a direction that increased the validation loss. This first-order score is closely related to gradient alignment attribution, but the In-Run Data Shapley perspective clarifies it as the Shapley value of a first-order approximated utility.

The method also includes a second-order approximation. The Taylor expansion of the local utility contains a curvature term involving the Hessian of the validation loss at wtw_twt​:

Ht(z(val)):=∇2ℓ(wt,z(val)).\mathbf{H}_t^{(z^{(\mathrm{val})})} := \nabla^2 \ell(w_t, z^{(\mathrm{val})}).Ht(z(val))​:=∇2ℓ(wt​,z(val)).

The second-order local utility is written as

U(2)(t)(S)=12(w~t+1(S)−wt)⊺Ht(z(val))(w~t+1(S)−wt).U_{(2)}^{(t)}(S) = \frac{1}{2} \left( \widetilde{w}_{t+1}(S) - w_t \right)^{\intercal} \mathbf{H}_t^{(z^{(\mathrm{val})})} \left( \widetilde{w}_{t+1}(S) - w_t \right).U(2)(t)​(S)=21​(wt+1​(S)−wt​)⊺Ht(z(val))​(wt+1​(S)−wt​).

With the second-order approximation U(t)≈U(1)(t)+12U(2)(t)U^{(t)} \approx U_{(1)}^{(t)} + \frac{1}{2} U_{(2)}^{(t)}U(t)≈U(1)(t)​+21​U(2)(t)​, the Shapley value still has a closed-form structure. The score for a training point zzz contains two main components:

ϕz(U)≈∑t=0T−1[−ηt∇ℓ(wt,z(val))⋅∇ℓ(wt,z)⏟direct influence of z+12ϕz(U(2)(t))⏟interaction term].\phi_z(U) \approx \sum_{t=0}^{T-1} \left[ \underbrace{ -\eta_t \nabla \ell(w_t, z^{(\mathrm{val})}) \cdot \nabla \ell(w_t, z) }_{\text{direct influence of } z} + \frac{1}{2} \underbrace{ \phi_z(U_{(2)}^{(t)}) }_{\text{interaction term}} \right].ϕz​(U)≈t=0∑T−1​​direct influence of z−ηt​∇ℓ(wt​,z(val))⋅∇ℓ(wt​,z)​​+21​interaction termϕz​(U(2)(t)​)​​​.

The interaction term can be expanded as

12ϕz(U(2)(t))=ηt22∇ℓ(wt,z)⊺Ht(z(val))(∑zj∈Bt∇ℓ(wt,zj)).\frac{1}{2} \phi_z(U_{(2)}^{(t)}) = \frac{\eta_t^2}{2} \nabla \ell(w_t, z)^{\intercal} \mathbf{H}_t^{(z^{(\mathrm{val})})} \left( \sum_{z_j \in \mathcal{B}_t} \nabla \ell(w_t, z_j) \right).21​ϕz​(U(2)(t)​)=2ηt2​​∇ℓ(wt​,z)⊺Ht(z(val))​​zj​∈Bt​∑​∇ℓ(wt​,zj​)​.

This term captures how the presence of other training points in the same batch affects the attributed value of zzz. Intuitively, if the batch contains many similar or duplicate points, the interaction term redistributes value among them, preventing a single redundant copy from receiving an outsized contribution. As a result, the second-order method measures both the usefulness of a data point with respect to the validation target and its uniqueness within the batch.

The efficient computation module is central to making the method practical. A direct implementation of the first-order estimator would require computing individual gradients for each data point in the batch, which cannot easily exploit ordinary mini-batch GPU training. The authors address this with a “ghost dot-product” technique. The name reflects that individual gradient vectors are never explicitly materialized. Instead, the method reuses quantities already produced during backpropagation.

For a linear layer, the output can be written as

s=aW,\mathbf{s} = \mathbf{a} \mathbf{W},s=aW,

where W\mathbf{W}W is the weight matrix, a\mathbf{a}a is the mini-batch input, and s\mathbf{s}s is the pre-activation output. For sample iii, the gradient of its loss with respect to W\mathbf{W}W can be expressed as an outer product between its input activation and its output gradient:

∂ℓ(i)∂W=∂ℓ(i)∂s(i)⊗a(i).\frac{\partial \ell^{(i)}}{\partial \mathbf{W}} = \frac{\partial \ell^{(i)}}{\partial \mathbf{s}^{(i)}} \otimes \mathbf{a}^{(i)}.∂W∂ℓ(i)​=∂s(i)∂ℓ(i)​⊗a(i).

To compute the dot product between gradients of two samples, the dot product over the outer-product structure can be decomposed into dot products of the smaller activation and output-gradient tensors. For two samples,

∂ℓ(1)∂W⊙∂ℓ(2)∂W=((a(1))Ta(2))((∂ℓ(1)∂s(1))T∂ℓ(2)∂s(2)).\frac{\partial \ell^{(1)}}{\partial \mathbf{W}} \odot \frac{\partial \ell^{(2)}}{\partial \mathbf{W}} = \left( \left(\mathbf{a}^{(1)}\right)^{\mathsf{T}} \mathbf{a}^{(2)} \right) \left( \left(\frac{\partial \ell^{(1)}}{\partial \mathbf{s}^{(1)}}\right)^{\mathsf{T}} \frac{\partial \ell^{(2)}}{\partial \mathbf{s}^{(2)}} \right).∂W∂ℓ(1)​⊙∂W∂ℓ(2)​=((a(1))Ta(2))((∂s(1)∂ℓ(1)​)T∂s(2)∂ℓ(2)​).

Both a(i)\mathbf{a}^{(i)}a(i) and ∂ℓ(i)/∂s(i)\partial \ell^{(i)} / \partial \mathbf{s}^{(i)}∂ℓ(i)/∂s(i) are already available during backpropagation. Therefore, the pairwise gradient dot products needed for the first-order attribution can be computed within the same backward pass used for the training batch. To include the validation point, the backward pass can be performed on the combined loss

∑z∈Btℓ(z)+ℓ(z(val)),\sum_{z \in \mathcal{B}_t} \ell^{(z)} + \ell^{(z^{(\mathrm{val})})},z∈Bt​∑​ℓ(z)+ℓ(z(val)),

which avoids a separate backward pass solely for the validation point. This design is the main reason the first-order In-Run Data Shapley method can run with minimal extra time beyond standard training.

For the second-order estimator, the challenge is larger because the interaction term requires gradient-Hessian-gradient products. The authors develop a related “ghost” computation that obtains these products with one extra backpropagation per iteration. Rather than forming full gradient-sized vectors for every sample or every data point, the technique exploits the layered structure of neural network gradients and reuses intermediate activations and output gradients. As a result, the second-order method requires approximately two backpropagations per training iteration: one for the combined training and validation computation, and one additional pass for the second-order interaction terms. This is still far cheaper than directly constructing all per-sample gradients and full second-order curvature quantities.

The overall training workflow can be viewed as a standard deep learning loop augmented with attribution bookkeeping. At each iteration, the system samples a batch, performs the usual forward pass, records or reuses the activation and output-gradient information needed for attribution, computes the local first-order contribution terms, optionally computes second-order interaction terms, accumulates per-point scores, and applies the regular parameter update. After training ends, the accumulated per-point scores form the In-Run Data Shapley attribution for the specific model checkpoint produced by that training run.

Experiment

The experiments evaluate In-Run Data Shapley in terms of runtime efficiency, approximation fidelity, and practical data attribution during language model pretraining. They show that the method is computationally feasible, accurately approximates Shapley values, and can identify negatively contributing training data whose removal improves convergence compared with influence-function-based filtering. Additional case studies demonstrate that data values change across training stages and that relevant training corpora can be detected even when outputs are heavily paraphrased, indicating that model behavior can be influenced without verbatim memorization.

The runtime evaluation shows that first order In Run Data Shapley using ghost dot product throughput is close to regular training throughput. Second order ghost computations are about two times slower than regular training because of extra backpropagation, but both ghost variants are much faster than direct per sample gradient implementations. These efficiency trends make first order and second order In Run Data Shapley more practical than naive approaches. Ghost dot product keeps first order Data Shapley throughput near regular training throughput. Ghost vector Hessian vector product yields second order Data Shapley throughput around half of regular training. Direct implementations have much lower throughput than ghost implementations for both first order and second order computations.

The experiment compares how ranking-based attribution scores the original corpus when validation data varies from paraphrases to topical rewrites. In-Run Data Shapley and the influence function keep the original corpus very high for closely related or semantically similar cases, while BM25 becomes much weaker once lexical overlap disappears. The influence function gives slightly less favorable ranks than In-Run Data Shapley, consistent with noisier leave-one-out estimation. Semantic attribution can surface the original corpus for rewritten or topically related data BM25 tracks verbatim similarity more than broader contribution relevance In-Run Data Shapley ranks the original corpus higher than the influence function in paraphrase cases

The experiments evaluate both the runtime efficiency and ranking behavior of In-Run Data Shapley against influence functions and BM25. They show that ghost-based computations make first-order and second-order attribution substantially more practical than direct per-sample implementations, with ghost methods maintaining throughput close to regular training. The ranking tests further show that semantic attribution methods can identify the original corpus under paraphrased or topically rewritten validation data, whereas BM25 relies too heavily on lexical overlap and becomes much weaker when such overlap disappears.


Créer de l'IA avec l'IA

De l'idée au lancement — accélérez votre développement IA avec le co-codage IA gratuit, un environnement prêt à l'emploi et le meilleur prix pour les GPU.

Codage assisté par IA
GPU prêts à l’emploi
Tarifs les plus avantageux

HyperAI Newsletters

Abonnez-vous à nos dernières mises à jour
Nous vous enverrons les dernières mises à jour de la semaine dans votre boîte de réception à neuf heures chaque lundi matin
Propulsé par MailChimp