Unlearning Traces the Influential Training Data of Language Models (2024)

Abstract: Identifying the training datasets that influence a language model’s outputs is essential for minimizing the generation of harmful content and enhancing its performance. Ideally, we can measure the influence of each dataset by removing it from training; however, it is prohibitively expensive to retrain a model multiple times. This paper presents UnTrac: Unlearning Traces the influence of a training dataset on the model’s performance. UnTrac is extremely simple; each training dataset is unlearned by gradient ascent, and we evaluate how much the model’s predictions change after unlearning. Furthermore, we propose a more scalable approach, UnTrac-Inv, which unlearns a test dataset and evaluates the unlearned model on training datasets. UnTrac-Inv resembles UnTrac, while being efficient for massive training datasets. In the experiments, we examine if our methods can assess the influence of pretraining datasets on generating toxic, biased, and untruthful content. Our methods estimate their influence much more accurately than existing methods while requiring neither excessive memory space nor multiple checkpoints.

heading: 1 Introduction
text: Large language models (LLMs) have had a significant impact on our society. They exhibit remarkable abilities (e.g., chain-of-thought reasoning) without being explicitly trained for such tasks. At the same time, LLMs also pose potential risks, such as the amplification of discrimination through the propagation of toxic language. LLMs are trained on a vast number of corpora via pretraining or refined through finetuning on diverse tasks. Although some efforts have been made to unravel the black box of LLMs (e.g., Grosse et al., 2023; Feng et al., 2023), it is still unclear which data sources cause their unprecedented abilities and potential harms.
Ideally, we can answer this question by removing each dataset from the training datasets and as-
sessing the change in the model’s performance after retraining (leave-dataset-out). However, since we need to retrain a model on each dataset, leavedataset-out is prohibitively expensive. Training data attribution overcomes this problem by approximating the influence with Hessian-based influence functions (HIF; Koh and Liang, 2017; Koh et al., 2019) or tracking changes in test loss during training (TracIn; Pruthi et al., 2020). However, HIF requires a large memory space to approximate the inverse Hessian (Schioppa et al., 2022), while TracIn generally needs multiple model checkpoints.
In this paper, we propose UnTrac, which traces the influence of a training dataset by unlearning it from a trained model (Figure 1). Leave-datasetout removes each training dataset and measures its influence by assessing the trained model’s performance on a test dataset. Analogous to leave-datasetout, UnTrac unlearns each training dataset and estimates its influence by assessing the unlearned model’s performance on a test dataset. Unlearning has been studied to eliminate sensitive data from a trained model (Cao and Yang, 2015; Ginart et al., 2019; Mehta et al., 2022) and has recently been applied to LLMs (Jang et al., 2023; Chen and Yang, 2023). Following Jang et al. (2023), we unlearn a training dataset using gradient ascent, in contrast to the gradient descent normally used in training. Interestingly, Schioppa et al. (2023) argued that influence functions can be regarded as an approximation of the effect of finetuning on a number of examples (e.g., unlearning mislabeled examples). With UnTrac, instead of using the approximations, we directly quantify the effect of unlearning.
When many datasets are used for training, UnTrac is computationally costly because unlearning must be run for every individual training dataset. To overcome this drawback, we propose UnTracInv as a scalable approach particularly effective for an increasing number of training datasets. UnTracInv “unlearns” a test dataset instead of training
6312
datasets and evaluates the unlearned model on training datasets. UnTrac-Inv requires only a single run of unlearning, and, as we will show, can be considered as an efficient approximation of UnTrac.
In our experiments, we first examine whether our methods can trace influential training tasks in the setting of finetuning. We created a dataset representing a mixture of synthetic tasks, designed to evaluate our method’s capability in assessing the influence of each task. In order to make this assessment more challenging, we have created task pairs that, while semantically distinct, require responses in the same format. Additionally, we include pairs that are nearly identical in content but demand responses in differing formats. By estimating the influence across these task pairs, we verify that our methods are not overly reliant on superficial similarities between tasks. In this controlled dataset, we show that our methods accurately assess the influence of training tasks, where we use the expensive leave-dataset-out method as the ground-truth, and are only slightly affected by the output format.
Next, we assess whether our methods can identify the source of harmful content generated by a pretrained language model. Using smaller open pretrained transformers (OPT-125M; Zhang et al., 2022), the influence of eight pretraining datasets is estimated. We use three test datasets: Toxigen (Hartvigsen et al., 2022), WinoBias (Zhao et al., 2018), and TruthfulQA (Lin et al., 2022), which contain toxic language, biased text, and false answers to various questions, respectively. We calculate the ground-truth influence of each training dataset and evaluate the correlation between the estimated influence and ground-truth influence. We demonstrate that our methods accurately estimate the influence of pretraining datasets, significantly
outperforming other influence functions. Finally, we investigate how hyperparameters affect the performance of our methods. We found that UnTrac works robustly as long as we use preconditioned gradient methods with higher learning rates and a sufficient number of training iterations. In contrast, UnTrac-Inv works well for large batch sizes while being relatively sensitive to the learning rate and the number of training steps.

heading: 2 Problem Formulation
text: Our goal is to estimate the influence of a training dataset on the model’s predictions on a test dataset. To formalize this goal, we assume the counterfactual that a model is trained on the mixture of all datasets except for a dataset Z: θ−Z . The groundtruth influence of the training dataset Z on a test dataset Z ′ is defined as Equation (1) using model θ−Z and θ0, which is trained on all datasets D.
Itruth(Z ′,Z)= N ′∑
j=1
L(z′j ,θ−Z)−L(z′j ,θ0)
(1) where z′j is the j-th batch in the test dataset Z ′, N ′ is the number of test batches, and L is the loss function. Koh et al. (2019) use all examples in the dataset to train the counterfactual model: θ−Z = argminθ ∑ z∈D\Z L(z,θ). This definition overly emphasizes the influence of large datasets, as, when removing them, the number of training examples drops substantially. However, when asking about the influence of a dataset, our primary interest often centers on whether the type of data present within a dataset wields considerable influence. We modify the definition of dataset’s influence so as to better align with this research question. Thus, for every
training dataset Z , we train a model for the same number of training steps T instead of the entire dataset: θ−Z = argminθ ∑T t=1 L(zt,θ) where zt ∼ D \ Z . This setup is practical for evaluating the influence of datasets of different sizes.1

heading: 3 Methods

heading: 3.1 UnTrac
text: Here, we formally introduce UnTrac, which estimates the influence of a training dataset on a test dataset by unlearning. Let Z ′ be a test dataset, θi be the model parameters after the i-th unlearning step (θ0 is the trained model parameters). The influence of a training dataset Z on a test dataset Z ′ is defined as the change in test loss due to unlearning.
I(Z ′,Z)= N ′∑
j=1
L(z′j ,θT )−L(z′j ,θ0)
= N ′∑
j=1
T∑
i=1
L(z′j ,θi)−L(z′j ,θi−1) (2)
where T is the number of unlearning steps. Here, θi is updated via gradient ascent, which maximizes the loss of the i-th batch zi in the training dataset Z . If we use stochastic gradient ascent, the updated parameters can be written as Equation (3); however, any optimizer can be used for unlearning.
θi = θi−1 + ηi∇θL(zi,θi−1) (3)

heading: 3.2 UnTrac-Inv
text: When many datasets are used for training, UnTrac is computationally costly because unlearning must be run for every training dataset. In a practical scenario, we are interested in detecting which training dataset influences a particular test dataset. Here, we introduce UnTrac-Inv, an alternative scalable approach that can handle an increasing number of training datasets. UnTrac-Inv unlearns the test dataset instead of training datasets and measures the change in loss on the training datasets. UnTracInv computes the influence by Equation (4).
I ′(Z ′,Z)= N∑
i=1
L(zi,θT ′)− L(zi,θ0)
= N∑
i=1
T ′∑
j=1
L(zi,θj)− L(zi,θj−1) (4)
1In Appendix A.1, we show the conventional leave-datasetout setup overestimates the influence of large datasets.
where N is the number of batches in the training dataset, and T ′ is the number of unlearning steps.
This alternative influence can be regarded as an approximation to UnTrac, Equation (2). Note that θj = θj−1+ηj∇θL(z′j ,θj−1), and we use the firstorder approximation L(zi,θj) − L(zi,θj−1) ≈ ∇θL(zi,θj−1)(θj − θj−1). Equation (2) and (4) can then be re-approximated as Equation (5) and (6), respectively.
I(Z ′,Z)
≈ T∑
i=1
N ′∑
j=1
ηi∇θL(zi,θi−1)⊤∇θL(z′j ,θi−1) (5)
I ′(Z ′,Z)
≈ N∑
i=1
T ′∑
j=1
ηj∇θL(zi,θj−1)⊤∇θL(z′j ,θj−1)
(6) If the number of unlearning steps is one (T = T ′= 1), and a single batch contains all examples, I(Z ′,Z) corresponds to I ′(Z ′,Z). This suggests that UnTrac-Inv should work well with a small number of unlearning steps and a large batch size. We will empirically validate it later in Section 6.1.

heading: 4 Relation to Other Influence Functions

heading: 4.1 TracIn, GradDot & GradCos
text: Pruthi et al. (2020) proposed TracIn, which traces the influence of a training example by the total change in test loss during training. While the original TracIn assesses the influence of individual training examples, it can be easily extended to assess a whole dataset. As accounting for the loss reduction at every step is computationally expensive, they approximate it using model checkpoints, assuming that every example in the training dataset is encountered once between these checkpoints. By approximating the loss reduction with gradients at each checkpoint t: L(z′j ,θt) − L(z′j ,θt+1) ≈ ηt∇θL(zi,θt)⊤∇θL(z′j ,θt), TracIn is defined as:
TracIn(Z ′,Z)
= ∑
t∈Tcp
N∑
i=1
N ′∑
j=1
ηt∇θL(zi,θt)⊤∇θL(z′j ,θt) (7)
where Tcp denotes the set of training steps where the model checkpoints are saved. As using multiple checkpoints induces substantial overhead, only the last checkpoint is often used in practice (Schioppa
et al., 2023), which is referred to as GradDot. Barshan et al. (2020) pointed out that some outlier training examples have significantly large gradients, leading to an overestimation of their influences. Therefore, normalizing the gradients (i.e., replacing the dot product with cosine similarity) can be effective, referred to as GradCos (Han and Tsvetkov, 2021; Akyurek et al., 2022).

heading: 4.2 Hessian-based Influence Functions
text: Hessian-based influence functions (HIF) are grounded in robust statistics (Hampel, 1974; Cook and Weisberg, 1982) and were introduced to deep learning by Koh and Liang (2017). Koh et al. (2019) used HIF to assess the influence of multiple training examples, and the estimated influence correlates well with the ground-truth. Given a trained model θ0, HIF estimates the influence of a training dataset Z on a test dataset Z ′ as Equation (8).
HIF(Z ′,Z)
= N∑
i=1
N ′∑
j=1
∇θL(zi,θ0)⊤H−1θ ∇θL(z′j ,θ0) (8)
where Hθ is the Hessian of training loss: Hθ = 1/N ∑N i=1∇2θL(zi,θ0).

heading: 4.3 Connection to UnTrac & UnTrac-Inv
text: GradDot, GradCos, and HIF can be viewed as special cases of UnTrac and UnTrac-Inv. Suppose a single training batch contains all training examples. The increase in test loss after a single step of unlearning can be approximated as Equation (9).
I(Z ′,Z)= N ′∑
j=1
L(z′j ,θ1)− L(z′j ,θ0)
≈ N ′∑
j=1
∇θL(z′j ,θ0)⊤(θ1 − θ0) (9)
When we use SGD, Equation (9) corresponds to GradDot by substituting θ1 − θ0 = η0 ∑N i=1∇θL(zi,θ0). Similarly, It corresponds to GradCos if we use RMSProp or Adam: θ1 − θ0 = η0 ∑N i=1∇θL(zi,θ0)/∥ ∑N i=1∇θL(zi,θ0)∥, and corresponds to HIF if we use Newton’s method: θ1 − θ0 = ∑N i=1H −1 θ ∇θL(zi,θ0). In the same way, these influence functions can also be regarded as a special case of UnTrac-Inv. HIF can be regarded as providing an approximation to UnTrac.

heading: 5 Experiments
text: We evaluate if our methods can measure the influence of training datasets across different model architectures (encoder-decoder and decoder-only) and training setups (pretraining and fine-tuning).2
Since we would not generally have a validation set (i.e., ground-truth attributions), it is impractical to tune the hyperparameters for each experiment. Thus, we set the hyperparameters based on the experimental results on Toxigen, one of the test datasets used in Section 5.2. The same hyperparameters are used across all the experiments. We use Adam (Kingma and Ba, 2014) with a constant learning rate of 5e-5, β1 = 0.9, and β2 = 0.999, while Adafactor is used in Section 5.1 due to memory constraints. Gradient clipping is turned off during unlearning. As for UnTrac, we set the batch size to 1 and run unlearning for 1 epoch. As discussed in Section 3.2, UnTrac-Inv requires a small number of unlearning steps and a large batch size. Hence, we set the batch size as 256 (a single batch contains all test examples) and the number of unlearning steps (epochs) as 5. In Section 6, we discuss the hyperparameter sensitivity of our methods.
The baseline methods are as follows:
TracIn, GradDot & GradCos We compute the gradient w.r.t. all of the model parameters. TracIn uses the checkpoints saved for every 128 steps in Section 5.1 and 10,000 steps in Section 5.2.
HIF Following Koh and Liang (2017), we approximate the inverse Hessian by LISSA (Agarwal et al., 2017), where the number of iterations is set to 10. We also use Arnoldi iteration with low-rank eigenvector projection following Schioppa et al. (2022). We set the number of Arnoldi iterations to n = 25 and the number of eigenvectors to p̃ = 25 in Section 5.1 due to the memory constraints, while n = 200 and p̃ = 100 in Section 5.2. Following the previous studies, the gradients of training datasets are normalized, and 256 training examples are used to approximate the Hessian of training loss.

heading: 5.1 Tracing Influential Training Tasks
text: We examine whether UnTrac can detect influential training tasks in the setting of finetuning. If a task is unlearned from a model, one may hypothesize that the model will no longer respond in the
2The code and data are available at: https://github. com/misonuma/untrac/. More implementation details are noted in Appendix A.2.
format required by the task, regardless of the input. Hence, we are concerned that unlearning not relevant tasks but those having the same answer format as a test task may adversely affect the test task’s performance. This may not be consistent with the leave-dataset-out ground-truth and, thus, lead to an overestimation of the non-relevant task’s influence. Using synthetic datasets, we show that UnTrac can assess the influence of training tasks properly, regardless of the output format.
Model We use T5 (Raffel et al., 2020) as a pretrained encoder-decoder model. Specifically, we use the LM-adapted T5-XL (3B), which is finetuned on language modeling (Lester et al., 2021).3
Dataset We create two synthetic datasets, each containing one test dataset and four training datasets. The test datasets contain examples of task P with the output format P (Task P/Format P). The task and output format of training datasets are set with respect to the test dataset as follows:
3https://huggingface.co/google/t5-xl-lm-adapt
1. Training dataset 1 (Task P/Format P): similar task P with the same output format P. 2. Training dataset 2 (Task P/Format Q): similar task P with different output format Q. 3. Training dataset 3 (Task Q/Format P): irrelevant task Q with the same output format P. 4. Training dataset 4 (Task Q/Format Q): irrelevant task Q with different output format Q.
Table 1 presents examples of the synthetic datasets A and B. Each training dataset and test dataset consists of 256 examples. The model is trained for 512 steps on the mixture of the four training datasets with a batch size of 2.
Results Table 2 presents the influence of training datasets estimated by each method and the groundtruth influence measured by leave-dataset-out. The ground truth indicates that datasets 1 and 2 (tasks similar to the test task) are more influential than datasets 3 and 4 (tasks irrelevant to the test task). The influence estimated by UnTrac and UnTracInv aligns well with the ground-truth influence. All
0.0 0.2 0.4 0.6 0.8 1.0 epoch
0 100 200 300 400 500 600 700 in flu en ce
UnTrac on the Synthetic Datasets A training dataset
1 (Task P/Format P) 2 (Task P/Format Q) 3 (Task Q/Format P) 4 (Task Q/Format Q)
0.0 0.2 0.4 0.6 0.8 1.0 epoch
0
200
400
600
800
in flu
en ce
UnTrac on the Synthetic Datasets B training dataset
1 (Task P/Format P) 2 (Task P/Format Q) 3 (Task Q/Format P) 4 (Task Q/Format Q)
0 10 20 30 40 50 epoch
0 20 40 60 80
100 120 140 160
in flu
en ce
UnTrac-Inv on the Synthetic Datasets A training dataset
1: SimSame 2: SimDiff 3: DisSame 4: DisDiff
0 10 20 30 40 50 epoch
0 50
100 150 200 250 300 350 in flu en ce
UnTrac-Inv on the Synthetic Datasets B training dataset
1: SimSame 2: SimDiff 3: DisSame 4: DisDiff
Figure 2: The influence estimated by UnTrac (top) and UnTrac-Inv (bottom) on the synthetic datasets A (left) and B (right). The line denotes the average across four runs, and the shaded area corresponds to 95% confidence region.
other methods assess the influence of dataset 4 as lower than that of other datasets. However, they tend to overestimate the influence of dataset 3 or underestimate it for datasets 1 and 2.
Figure 2 shows the change in influence estimated by UnTrac and UnTrac-Inv on the synthetic datasets A (left) and B (right), respectively. For both synthetic datasets, our methods estimate the influence of datasets 1 and 2 as greater than that of datasets 3 and 4 across unlearning steps. These results indicate that UnTrac and UnTrac-Inv appropriately estimate the influence of training datasets in terms of the relevance of tasks and do not seem overly affected by the output format.

heading: 5.2 Tracing Influential Pretraining Corpora
text: LLMs sometimes generate toxic, biased, and false content, which must be prevented to safely use language models. We next verify that our methods can identify the influence of a pretraining dataset on the generation of harmful content.
Model We use an open pre-trained transformer language model (OPT; Zhang et al., 2022). As computing ground-truth influence for pretraining datasets is expensive, we use a relatively small language model with 125 million parameters.4 OPT is pretrained for 40,000 steps with a batch size of 8 on the datasets described below.
4https://huggingface.co/facebook/opt-125m
Dataset We use eight pretraining datasets that were used for OPT: BookCorpus (Zhu et al., 2015), CC-Stories (Trinh and Le, 2018), CCNewsV2 (Liu et al., 2019), and five subsets in the Pile dataset (Gao et al., 2020): PJ Gutenberg, HackerNews, OpenWebText2, Pile-CC, and Wikipedia. To investigate whether our methods are effective regardless of the dataset’s proportion, we set up two settings: one where each pretraining dataset contains an equal number of examples (40,000) and another where they contain different numbers of examples (Pile-CC: 96,000, OpenWebText2: 64,000, CCNewsV2: 48,000, BookCorpus: 32,000, Stories: 32,000, PJ Gutenberg: 16,000, HackerNews: 16,000, Wikipedia: 16,000). Each training example consists of a sequence of 1,024 tokens by grouping several examples into a sequence.
In practice, computing influences using the whole pretraining dataset is quite expensive. Thus, we randomly sample 10,000 examples from each dataset to estimate its influence. To ensure that the reported results are invariant to the choice of examples, we report the average and standard deviation across four runs using different examples.
Regarding test datasets, we use three datasets: Toxigen (Hartvigsen et al., 2022), WinoBias (Zhao et al., 2018), and TruthfulQA (Lin et al., 2022). ToxiGen collects machine-generated toxic language against several minority groups. Winobias contains sentences with entities corresponding to
people referred to by their occupation and their pronoun genders. TruthfulQA comprises questions across several categories and their corresponding untruthful answers. We measure the negative logprobability of toxic language, biased text, and false answers to compute the influences.
Results Table 3 shows the Pearson correlation coefficient between the estimated influence and the ground truth assessed by leave-dataset-out.5 As there are only eight pretraining datasets, the correlation between ground truth and estimated influences cannot be statistically significant. Therefore, we divided the test dataset into multiple subsets and aggregated the correlation for each subset to enhance the reliability of the results. We reported the average across 13 subsets for ToxiGen, 4 subsets for WinoBias, and 9 subsets for TruthfulQA.
Across all datasets and settings, the estimated influence by UnTrac and UnTrac-Inv correlates well with the ground truth. GradCos, GradDot, and
5The same tendency is confirmed when Spearman’s rank correlation coefficient is used as a metric (Appendix A.3).
HIF (Arnoldi) perform well on Winobias. However, they show lower performance on Toxigen and TruthfulQA specifically when the dataset sizes are unbalanced. The performance of HIF (LISSA) is unstable, as indicated by the high variance in its score. While TracIn achieves a relatively higher correlation with equally sized training datasets, its performance declines when the sizes are different.
We found that the influences estimated by existing methods are not significantly different across training datasets. For WinoBias and TruthfulQA, the ground-truth influence of each pre-training dataset does not differ that much. Thus, the existing methods achieve high correlations on those datasets as well as ours. In contrast, on ToxiGen, the ground-truth influences of pre-training datasets vary significantly; Pile-CC and BookCorpus are more influential than others. Our methods can detect these influential datasets, while other approaches fail, leading to higher performance of our methods on ToxiGen. These results indicate that our methods can robustly trace the influence of pretraining datasets regardless of their proportions.

heading: 6 Discussion
text: In this section, we explore how hyperparameters affect the performance of our methods. Following the experiment in Section 5.2, we compute the influence of the pretraining dataset on Toxigen under various hyperparameter settings, where the size of each training dataset is set to be equal. By monitoring the Pearson correlation coefficient between the estimated influence and ground truth, we investigate the hyperparameter sensitivity of our methods.

heading: 6.1 Sensitivity to Epoch & Batch Size
text: Figure 3 shows the performance of UnTrac and UnTrac-Inv over unlearning epochs with batch sizes of 1 and 256. On both batch sizes, UnTrac achieves high and stable performance as the number of unlearning epochs increases. In contrast, UnTrac-Inv shows entirely different tendencies. When the batch size is one, UnTrac-Inv performs poorly over the entire run of unlearning. When the batch size is 256, the performance of UnTrac-Inv rises for the first several epochs, while it degrades gradually after a while. As discussed in Section 3.2, UnTrac-Inv approximates UnTrac when unlearning is run for a small number of steps with a large batch size. When the number of unlearning steps is large or the batch size is small, UnTrac-Inv deviates from UnTrac and does not perform well.
These observations may suggest why other influence functions perform worse. As mentioned in Section 4.3, GradDot, GradCos, and HIF can be regarded as approximations of UnTrac (and UnTracInv) when unlearning is conducted for a single step. As shown in Figure 3, UnTrac and UnTrac-Inv underperform when the number of unlearning steps is one. From the viewpoint of unlearning, a single step is often insufficient to fully trace the influence of training datasets, suggesting why other influence functions underperform.

heading: 6.2 Sensitivity to Optimizer & Learning Rate
text: Here, we discuss how the choice of optimizers and learning rate affects the performance of our methods. Table 4 shows the performance of each method across different optimizers and learning rates, while fixing other hyperparameters.
Optimizer Table 4 (top) shows the performance with various optimizers. We use SGD, SGD with momentum (momentum = dampening = 0.9), RMSProp (Tieleman et al., 2012; α = 0.99), Adam, and Adafactor (Shazeer and Stern, 2018). UnTrac performs well when RMSProp, Adam, and Adafactor are used, indicating that a preconditioner plays an important role in unlearning.
A similar trend can be seen for UnTrac-Inv, though it performs worse when RMSProp is used. We suspect this is because both Adam and Adafactor use a decaying average of gradients, rather than just the gradient for the current batch as RMSProp and SGD do. This makes training less stochastic and has a somewhat similar effect to using larger batches, which is beneficial for UnTrac-Inv.
Learning Rate Table 4 (bottom) presents the performance with several learning rates. UnTrac performs well across various learning rates when using higher learning rates. With lower learning rates, UnTrac does not converge and performs unstably.
In contrast, UnTrac-Inv is somewhat sensitive to the choice of learning rate. Following the discussion in Section 3.2, UnTrac-Inv diverges from UnTrac as unlearning proceeds. As a higher learning rate boosts the divergence, increasing the learning rate does not necessarily lead to higher performance. However, the estimated influence correlates positively with ground truth on any learning rate.

heading: 7 Related Work
text: Which training data affects the model’s prediction? The importance of this question has been rising
along with the emergence of LLMs trained on massive text corpora (Akyurek et al., 2022; Longpre et al., 2023; Feng et al., 2023; Han et al., 2023; Grosse et al., 2023). Hessian-based influence functions (Hampel, 1974; Koh and Liang, 2017) are pioneering work to address this question and are widely used in the context of natural language processing (Han et al., 2020; Guo et al., 2021; Yang et al., 2023). As computing inverse Hessian is quite expensive (Guo et al., 2021; Schioppa et al., 2022; Grosse et al., 2023), TracIn is another promising approach for training data attribution (Pruthi et al., 2020). However, several studies empirically reported that these methods are unstable for deep neural networks (Basu et al., 2021; Søgaard, 2021).
While the studies above focus on a single training example, several studies consider the influences of multiple training examples (Koh et al., 2019; Barshan et al., 2020). Basu et al. (2020) argue that the first-order approximation behind influence functions is unsuitable, as removing multiple examples leads to a significant perturbation of model parameters. Schioppa et al. (2023) theoretically show that influence functions work well for a limited number of training steps, but are unlikely to be good approximators of leave-one-out influences. Therefore, they used influence functions to detect influential training examples of mispredictions. By flipping the label of the influential training examples and training a model on the flipped examples, the mispredictions can be corrected with a few finetuning steps. Whereas they use influence functions to detect influential examples to be unlearned, we use unlearning to detect influential examples.
Sampling-based attribution methods, such as Shapley values (Ghorbani and Zou, 2019), empirical influences (Feldman and Zhang, 2020), and datamodels (Ilyas et al., 2022) are also promising approaches for tracing influential training datasets. However, they commonly require thousands of pairs of training subsets and models trained on the subsets to estimate how the combination of training examples affects the model’s performance. Although TRAK (Park et al., 2023), a recent sampling-based approach, requires significantly fewer computational resources than others, it still requires tens of pairs of training subsets and their corresponding trained models, which can be costly as well as leave-dataset-out. Indeed, TRAK was evaluated only on fine-tuning setups in its original paper. On the other hand, we study approaches that are scalable to large pretraining datasets.
Unlearning has been studied to remove undesired data from a trained model (Cao and Yang, 2015; Golatkar et al., 2020; Sekhari et al., 2021; Gupta et al., 2021) and has recently been used for LLMs (Jang et al., 2023; Wang et al., 2023; Yao et al., 2023; Maini et al., 2024; Zhang et al., 2024; Jia et al., 2024).

heading: 8 Conclusion
text: This paper explored unlearning approaches to trace the influence of training datasets. Our approach, UnTrac, simply unlearns each training dataset and evaluates how the model’s performance changes on a test dataset after unlearning. UnTrac-Inv is a more scalable approach, which unlearns a test dataset and evaluates the unlearned model’s performance on training datasets. Experimental results showed that our methods can trace the influence of training datasets with significantly higher accuracy than existing methods. UnTrac works robustly if we use preconditioned optimizers with high learning rates and a sufficient number of training steps. In contrast, UnTrac-Inv is relatively sensitive to the choice of hyperparameters, such as batch size, learning rate, and the number of training iterations.
As our methods require the same memory footprint as standard training, they can be applied to LLMs as long as we have enough memory space for training. In future work, we hope that the effectiveness of our methods will be investigated with even more large models, and that our methods will be helpful in revealing the source of LLM’s emergent abilities, such as chain-of-thought reasoning.
Limitations
Although our methods are assessed across different model architectures, model sizes, and training setups, further empirical investigations are expected to verify their effectiveness. We do not argue that our methods are immediately applicable in practical use. For real-world applications, we need to validate our methods in various settings and tasks against leave-dataset-out, though leave-dataset-out requires considerable computational cost.

heading: Acknowledgements
text: MI is supported by JST CREST JPMJCR21D1, NEDO JPNP20006, and JSPS KAKENHI 23K16940, Japan. IT is supported by the Dutch National Science Foundation (NWO Vici VI.C.212.053).

heading: A Appendix
text: A.1 How to Compute Leave-Dataset-Out
Figure 4 shows the ground-truth influence assessed by leave-dataset-out where the pertaining dataset sizes are varied and ToxiGen is used as a test dataset (see Section 5.2). Leave-datasetout assumes a counterfactual model that is trained on the mixture of all training datasets D except for a dataset Z . In the left figure, the counterfactual model is trained on all the examples except for the training dataset Z: θ−Z = argminθ ∑ z∈D\Z L(z,θ). The influence of large datasets is higher because the size of D \ Z becomes smaller, and the performance of model θ−Z largely depends on the dataset sizes. In the right figure, each counterfactual model is trained for the same number of training steps T : θ−Z = argminθ ∑T t=1 L(zt,θ) where zt ∼ D \ Z . This setup does not overestimate the influence of large datasets. In a practical scenario, we want to figure out which training datasets should be used under a fixed computational resource. Thus, the influence
of each training dataset should be compared under the same number of training steps.
A.2 Implementation Details
Our code is implemented with Python v3.8.13, PyTorch v1.12.0 (Paszke et al., 2019), and Transformers v4.18.0 (Wolf et al., 2020). In Section 5.1, we used the synthetic datasets which are originally created in this study. The numbers used in the output text range from 1 to 256, while the characters and their part of speech are collected from WordNet (Miller, 1994, WordNet 3.0 license). Our study was conducted under the licenses and terms of the scientific artifacts.
Our experiments were conducted with a single NVIDIA A100 (80GB) for each run in Section 5.1 and a single Tesla V100 (16GB) for each run in Section 5.2. Unlearning each training dataset (UnTrac) takes approximately two minutes in Section 5.1 and four hours in Section 5.2. Unlearning each test dataset (UnTrac-Inv) takes approximately one minute in Section 5.1 and 30 minutes in Section 5.2, not including the time required for evaluation.
A.3 Evaluation by Spearman Correlation Table 5 shows the Spearman’s rank correlation between the estimated influence and the ground-truth influence computed by leave-dataset-out in Section 5.2. The tendency is similar to the result shown in Table 3, which uses the Pearson correlation as an evaluation metric. Across all datasets and settings, the estimated influence by UnTrac and UnTrac-Inv correlates well with the ground truth.

heading: Future Work
text: In future work, we hope that the effectiveness of our methods will be investigated with even more large models, and that our methods will be helpful in revealing the source of LLM’s emergent abilities, such as chain-of-thought reasoning. Limitations
Although our methods are assessed across different model architectures, model sizes, and training setups, further empirical investigations are expected to verify their effectiveness. We do not argue that our methods are immediately applicable in practical use. For real-world applications, we need to validate our methods in various settings and tasks against leave-dataset-out, though leave-dataset-out requires considerable computational cost