A Taxonomy for Data Contamination in Large Language Models (2024)

Abstract: Large language models pretrained on extensive web corpora demonstrate remarkable performance across a wide range of downstream tasks. However, a growing concern is data contamination, where evaluation datasets may be contained in the pretraining corpus, inflating model performance. Decontamination, the process of detecting and removing such data, is a potential solution; yet these contaminants may originate from altered versions of the test set, evading detection during decontamination. How different types of contamination impact the performance of language models on downstream tasks is not fully understood. We present a taxonomy that categorizes the various types of contamination encountered by LLMs during the pretraining phase and identify which types pose the highest risk. We analyze the impact of contamination on two key NLP tasks—summarization and question answering—revealing how different types of contamination influence task performance during evaluation.

heading: 1 Introduction
text: Advancements in machine learning have traditionally relied on benchmark datasets to evaluate and compare model performance (Raji et al., 2021; Gururaja et al., 2023). With the surge of large language models (LLMs) in recent years, these benchmarks are now leveraged to showcase remarkable abilities across diverse tasks.
However, the shelf life of benchmarks is incredibly low, with Roberts et al. (2023) demonstrating that newer models with updated training cutoff dates are iteratively rendering existing benchmarks stale. The presence of internet-sourced data in both pretraining and evaluation datasets increases the risk of data contamination (Brown et al., 2020; Magar and Schwartz, 2022) and challenges the notion of fair evaluation for models pretrained on massive corpora. Both GPT-3 and C4 training corpora were found to contain test data for several benchmarks
(Dodge et al., 2021; Raffel et al., 2020; Brown et al., 2020), raising serious concerns about the validity of evaluation scores for many pretrained models (Lee et al., 2022; Chang et al., 2023b).
The research community lacks consensus on best practices for data contamination, and different works define contamination in subtly different ways. Without standardization of terminology, it is difficult to develop best practices for contamination– or even to characterize the problem at all. To address this gap, we suggest a formal definition of contamination and taxonomize subtypes of contamination (§ 2). We map prior work on both the detection and impact of contamination into this taxonomy, revealing several understudied forms of contamination (§ 2.3). We also measure the impact of different types of contamination on downstream summarization (§ 4) and QA (§ 5) performance through continued pretraining experiments assessing indirect/approximate test set contamination effects.
Our findings reveal that for GPT-2 Large models, it is often the case that having in-domain data present during training is as beneficial as having the test data present during training. Moreover, we observe that certain contamination types exhibit task-dependent effects on evaluation performance, further complicating decontamination best practices. Our findings enable recommendations for identifying and mitigating problematic contamination during LLM development to ensure reliable evaluations (§ 7).

heading: 2 Taxonomy
text: Consider a model M : X → Y which, given an input of some type x ∈ X , outputs text ŷ ∈ Y . While x can be of any format, we will restrict ourselves to cases where ŷ is in the space of the natural language (Y ⊆ Σ∗ for some alphabet in Σ). Let D be the test set, consisting of |D| examples ⟨xi, ŷi⟩.
22

heading: 2.1 Contamination
text: We define contamination as any leakage of information that provides a signal for the correct label for at least one example in the test set D. When contamination occurs, some subset of the pretraining data can be characterized as the result of a function f(D), which may be a composition of multiple contamination functions f = f (1) ◦ f (2) ◦ · · · ◦ f (n). We characterize types of contamination by their dataset-level (§ 2.1.1) and example-level (§ 2.1.2) properties. Figure 1 provides an overview of our taxonomy.

heading: 2.1.1 Dataset-level Properties
text: For dataset-level contamination, consider a function g that leaves the individual examples ⟨xi, ŷi⟩ intact. In the simplest case, g is the identity function; this is the leakage of a full test set, e.g. from scraping a file containing the test set instances and labels. The following are types of functions g(D) can take on.
• Selection: A function that selects some group of examples D′ ⊂ D, such that only a subset of the test set is leaked. This is likely when the test data is drawn from several sources, only some of which appear in the pretraining data; when some of the test data is more recent than other data and the pretraining data contains an older snapshot of the contamination source; or when the data is contained in several documents and the cleaning of the pretraining data only removes some of these documents. Ver-
batim contamination refers to when g is the identity function.
• Distribution: A function which combines the contaminated data D with some additional, non-contaminating documents, such that the examples from D are not all sequential in the pretraining data. This can occur during data shuffling, or if the contamination comes from multiple documents. Practically, this means that the contaminated region of the pretraining data g(D) spans more tokens.

heading: 2.1.2 Instance-level Properties
text: In instance-level contamination, the function f applies some function h to each individual leaked example f(D) = {h(⟨xi, ŷi⟩)}|D|i=1.1 A few representative examples in this class are enumerated below:
• Masking: A function that removes some or all of the input (can be done in combination with the output), e.g. h(⟨xi, ŷi⟩) = ŷi or removing all incorrect answer choices in a multiple choice question. This primarily qualifies as contamination for generation tasks; for a classification task, leaking the label-space in advance may not be a concern if the labels don’t have inherent contextual value without the input, such as binary labels like 0s and 1s or positives and negatives. However, if the
1Note that this is a strict subset of all functions applied to the leaked dataset, f(D); however, we distinguish this set of functions that operate on individual examples.
labels carry meaningful information on their own, their premature disclosure would indeed constitute contamination. Note that masking all of the output, leaving only the inputs from the test set, is generally considered to be a type of transductive learning, not contamination; see § 2.2.3 for more discussion.
• Noising: A function that modifies the surface form of the example, e.g. by paraphrasing the inputs or outputs, by presenting the output before the input, or by using silver rather than gold labels for each example. Note that this can also take the form of alternate correct answers being present in the pretraining data: for instance, in book summarization, a different summary of the book being present in the pretraining data is still contamination.
• Augmenting: A function that adds additional context, which may or may not be relevant to the example. For instance, for a task where the model must answer an open-ended question at test time, an augmented contaminated example in pretraining would be a multiplechoice test with the same questions. While this provides the correct answer, it also introduces new (distractor) information that is not present at test time. Another example would be including additional context paragraphs for QA in addition to the necessary context and answer. Note the difference between examplelevel augmenting and dataset-level distribution.

heading: 2.2 Phenomena that aren’t Contamination
text: For clarity, we describe several phenomena that lead to improved performance on test sets downstream but are not considered contamination under our taxonomy.

heading: 2.2.1 Language Understanding
text: Pretraining enables models to produce (generally) fluent text and encodes some representation of meaning for words commonly used in task definitions; for instance, the model has some representation of meaning for the labels “positive” and “negative” in sentiment analysis. While this representation is likely helpful for performing downstream tasks (Min et al., 2022), this is not inherently contamination.

heading: 2.2.2 Prior Task Understanding
text: We define prior task understanding as an ability to perform a task learned from non-contamination sources, and such prior knowledge has been demonstrated to boost model performance when evaluated on unseen instances of said task (Li and Flanigan, 2023). For instance, fine-tuning a model on a training dataset for the task is clearly not contamination of the test set, although it generally improves performance on that test set; likewise, pretraining on other related datasets is not contamination for a given test set. For closed-book QA and tasks requiring world knowledge, prior task understanding from training data is essential. Closed-book QA demands answering without external resources, relying solely on the model’s training on similar question-answer pairs or related datasets.
In general, scrutinizing the training data’s sources and nature is crucial to maintain model integrity and generalizability. Prior task understanding may violate the assumption of “zero-shot” performance: that the model has not seen training data for that task.

heading: 2.2.3 Transductive Learning
text: Transductive learning (Vapnik, 1998) incorporates an unlabeled test set into training. During training, the raw text inputs of the test set can be used, but the labels are not seen. The model, once trained, is then evaluated on the same test set during the test phase. Transductive LM fine-tuning has shown to consistently improve neural models in both indomain and out-of-domain settings (Ouchi et al., 2019), although concerns have been raised about blurring the line between training and evaluation (Jiang et al., 2024).
We generally do not consider pretraining on the inputs of the test set to be contamination,2 although we note that this will likely improve performance, in the same manner than pretraining on training set text improves downstream performance by providing some domain adaptation to the testing domain (Gururangan et al., 2020; Krishna et al., 2023). Some prior work refers to the presence of inputsonly in the pretraining data as contamination for classification tasks (Jiang et al., 2024; Ouchi et al., 2019); however, under our taxonomy, we consider this a type of transductive learning.
2A key exception is tasks where the input/output distinction does not apply, such as perplexity evaluation on a dataset D = {x1, . . . , x|D|} of sentences xi.

heading: 2.3 Mapping prior work exploring contamination into this taxonomy
text: The effects of selection have been explored by experiments that compare LLM performance over time (Li and Flanigan, 2023; Cao et al., 2024), prompting the model to generate samples from specific dataset splits (Sainz et al., 2023b), and training LLMs that select some subset of an evaluation dataset (Zhang et al., 2023; Jiang et al., 2024).
Jiang et al. (2024) also explores the effects of the frequency in which contaminated data appears distributed throughout the pretraining data.
Through zero-shot experimentation on the Codex model (Chen et al., 2021), Karmakar et al. (2022) investigates the effects of prompts masking out input specifications and prompts with augmented objectives. Additionally, Yang et al. (2023) showcases memorization of evaluation samples by prompting LLMs with noisy samples.
A prior position paper (Sainz et al., 2023a) defined three categories of data contamination: their guideline contamination falls under our definition of prior task understanding; their raw text contamination is tranductive learning; and their annotation contamination equates to our definition of data contamination in § 2.1. Our work further categorizes and explores types of annotation contamination.

heading: 2.4 Detecting Data Contamination
text: Methods with access to pretraining data Early research on LLM data contamination primarily employed methods akin to high-order n-gram overlap detection between pretraining and evaluation data (Radford et al., 2019a; Brown et al., 2020; Wei et al., 2021; Touvron et al., 2023). Tools for qualitative analysis on large-scale corpora (such as Data Portraits (Marone and Durme, 2023) and the ROOTS Search Tool (Piktus et al., 2023)) have further increased the practicality of this type of contamination detection. However, these approaches have several limitations: they remain fairly computationally expensive, assume access to pretraining data, and generally can only detect contamination when a cluster of several test set examples co-occur (as most methods leverage data sketching (Broder, 1997) tools that are only effective for sequences above a certain length).
Yang et al. (2023) proposes an LLM-based decontamination method, which leverages embedding similarity search followed by evaluation with a strong language model (e.g. GPT-4), to identify
and mitigate contamination. This is computationally costly but can identify noisy contamination
Methods without access to pretraining data Some approaches are capable of detecting contamination without direct access to pretraining data, but assume that the test data has not been modified or distributed across the pretraining corpus. These methods leverage metadata from the dataset to detect contamination, e.g. by leveraging dataset ordering (Sainz et al., 2023b) or the assignment of examples to specific data splits (Golchin and Surdeanu, 2023). Golchin and Surdeanu (2024) introduce the Data Contamination Quiz, a streamlined method that efficiently detects and estimates verbatim contamination in LLMs by crafting multiple choice questions that prompt a model to correctly dataset-specific content among similar but noisy alternatives.
Chang et al. (2023a) detect contamination of books (which serve as inputs for many long-context evaluation datasets) using domain specific features– a name cloze test and a publication-year evaluation. This is powerful for detecting the presence of the exact text of the book, but its efficacy on detecting related artifacts (e.g. summaries of the book, which may serve as test set outputs) is unknown.
Shi et al. (2023) introduces a new detection method MIN-K% PROB, which is capable of detecting whether a piece of text was in the pretraining corpora by leveraging the variability of the tokens’ probabilities according to the model. This has the potential to detect distributed or masked contamination, but is not robust to noising operations, which change the token sequence.
Most contemporary data-contamination detection techniques are designed to identify contamination of full, non-distributed test datasets, resulting in a significant gap in detecting noisy or partial contamination. The methods most well-adapted to detect noisy contamination, while powerful, require access to pretraining data and expensive operations; more work is necessary to lower the barrier to detection.

heading: 3 Methodology
text: In all our experiments, we employ GPT-2 Large (Radford et al., 2019b).3 This will be referred to as the initial model. Since the pretraining corpus for GPT-2 is not publicly accessible, there is a chance
3Our implementation uses nanoGPT (Karpathy, 2023) initialized with OpenAI’s gpt2-large weights.
that these learned weights of GPT-2 might be contaminated. Consequently, the outcomes of our experiments serve as a conservative estimate or lower bound on the effects of data contamination.
For each of our datasets, we create train/in-domain/test splits of equal size, aiming to establish a fair and comparable evaluation environment. To disentangle the effects of exposure to test data during pretraining from those of prior task understanding, we constructed an in-domain data split, allowing us to train models on task-relevant but uncontaminated data for comparison against the various contaminated settings. To partially mitigate the potential recency bias from continued pretraining, we incorporate an additional 10,000 samples of Open AI’s WebText (Radford et al., 2019b) into the continued pretraining data.
During continued pretraining, we use a blocksize of 1024 tokens with a batchsize of 1. For finetuning, the training data is seen sample by sample. To obtain deterministic results during our experiments, we set the temperature to zero and capped the maximum completion length at 200 tokens.

heading: 3.1 Training Settings
text: We consider several settings for incorporating data:
• ZERO-SHOT (not contamination): prompt the initial model with the test sample and a simple instruction for the task. • BASELINE (not contamination): finetune initial model with train split • CHEATING (contamination at fine-tuning time, rather than pre-training): finetune initial model with test split • Contamination Setting(s) (standard contamination during pretraining): continued pretraining with f (test split) and finetune with train split; the details of each contamination setting are specific to the task (§ 4 and § 5) • In-Domain Setting(s) (not contamination): continued pretraining with f (in-domain split) and finetune with train split—for each contamination setting in § 4 and § 5, there is an associated in-domain model.
For each setting+dataset, we average results over models trained on 3 random shuffles of the data. Standard deviations are computed over these 3 runs and error bars indicate ± one standard deviation.

heading: 4 Case Study: Summarization
text: For this case study, we use the following summarization datasets: XSum (Narayan et al., 2018), SAMSum (Gliwa et al., 2019), and CNN/Daily Mail (Nallapati et al., 2016). We explore 5 contamination settings:
1. VERBATIM (dataset level, selection): f = identity function on test split 2. DISTRIBUTION (dataset level, distribution): f = shuffle test data with WebText 3. MASKED (instance level, masking): h = mask out input documents in test split 4. NOISED (instance level, noising): h = swap in GPT-3.54 generated summaries on test split 5. REFORMATTED (instance level, noising): h = swap format from document-summary to summary-document for test data
Table 5 provides examples of each setting.

heading: 4.1 Results
text: In this section, we consider the overall performance of each contamination method across summarization datasets. Figure 2 shows an example of the results from one task and one metric (SAMSum, ROUGE-L). See Appendix A for full results on all tasks and metrics, specifically Figures 4, 5, 6 or Table 3.
Consistently, the CHEATING setting outperforms all others; this is expected, given that deliberately finetuning on the test data is an extreme form of contamination.
Overall, continued pretraining with the approximate contamination methods improves performance above the BASELINE setting, often substantially. This suggests that exposure to these forms of contamination during pretraining can impact the reliability of evaluations on this data downstream.
While VERBATIM setting performs slightly better than the other contamination settings, this improvement isn’t significant for most settings. Note that most contaminated settings outperform the baseline, and exist within a standard deviation of each other. This suggests that the performance boost may simply be attributed to the increase in in-domain data seen during the training stage rather than encountering the test split during continued pretraining.
Note that for the most part, the VERBATIM and INDOMAIN-VERBATIM settings perform on par
4gpt-3.5-turbo-0125 with temperature=0.5
with each other. This trend seems to hold true for the other contamination and in-domain model pairs. The comparable performance further suggests that exposure to contaminated data may not be the primary factor boosting model performance in the contamination settings studied.
While the majority of these settings have metrics that fall within one standard deviation of each other, there are exceptions. For instance, in the case of the XSum dataset, the NOISED setting fails to surpass the BASELINE. This discrepancy can be attributed to the idiosyncrasies of the XSum dataset, where ground truth summaries may deviate significantly from typical summaries, thus posing a challenge for the model in generating accurate outputs. Table 1 shows that the summaries generated by GPT-3.5 (Brown et al., 2020) for the XSum dataset have lower rouge scores than the other two datasets.
Additionally, underperformance of the MASKED contamination setting compared to the BASELINE across all datasets is noteworthy, suggesting that exposure only to summaries during pretraining may fail to achieve the benefits of seeing in-domain data.

heading: 5 Case Study: Question Answering
text: For this case study, we consider open-ended QA with SQuAD (Rajpurkar et al., 2016) and multiple-
choice QA with the Children’s Book Test (CBT) (Hill et al., 2016). We explore 6 contamination settings:
1. VERBATIM (dataset level, selection): f = identity function on test split 2. DISTRIBUTION (dataset level, distribution): f = shuffle test data with WebText 3. MASKED (instance level, masking): h = mask out context passage in test split 4. NOISED (instance level, noising): h = encounter GPT-3.5 generated answers to test split questions 5. REFORMATTED (instance level, augmenting/masking)5: hSQuAD = introduce 3 distractor multiple choice answer options; hCBT = mask out incorrect answer options 6. AUGMENTED (instance level, augmenting): h = prompt GPT-3.5 to add additional content to the context passages in the test split
Table 6 provides examples of each setting.

heading: 5.1 Results
text: In this section, we consider the overall performance of each contamination method across Question Answering datasets. Figure 3 shows an example of the results from one task and one metric (SQuAD, Exact Match). See Appendix B for full evaluation results on all tasks and metrics, specifically Figures 7, 8 or Table 4.
Once again, the CHEATING setting outperforms all others by a noticeable margin. With the exception of the MASKED setting for the SQuAD
5For SQuAD, this is a form of augmented contamination, as additional (distractor) information is introduced. For CBT, this is a form of masked contamination, as information is removed.
dataset, all contaminated settings exhibit better performance compared to the BASELINE setting by a considerable margin. This indicates that the increased data diversity experienced by both the indomain and contaminated models during training improved their performance during evaluation.
Note that the NOISED setting performs almost as well as the VERBATIM contamination setting. We attribute this to the fairly high quality of silver labels generated by GPT-3.5 (see Table 2).
Exposure to in-domain data during pretraining appears to improve model performance. However, our results show that contaminated settings such as NOISED, VERBATIM, and DISTRIBUTION tend to outperform the corresponding in-domain settings during evaluation. This suggests that seeing data from the test set positively impacts model performance for question answering tasks. Note that for these three model setups, the format of context, question, and answer is almost consistent with the format and content seen during evaluation time.
Reformatting (augmenting) free-form questions from SQuAD into multiple-choice answers during pretraining appears to have a negative effect on model performance, though it still outperforms the BASELINE setting. Conversely, converting multiple-choice questions from CBT into free-form questions (masking) during pretraining yields positive results, with the REFORMATTED setting outperforming most other contaminated settings.
Furthermore, we observe variations in the performance of AUGMENTED setting across the two datasets. While this setting perform well for SQuAD, its performance is not as impressive for CBT. This discrepancy may be attributed to the nature of data augmentation, where the additional information provided for SQuAD is more relevant and beneficial to the wikipedia paragraphs compared to the irrelevant introductions, such as ‘once upon a time’ style introductions generated by GPT3.5 for these book excerpts, added to CBT stories. It is important to note that since this information doesn’t significantly contribute to the task, this form of augmentation falls in a blurry space between distribution and augmentation branches of the taxonomy. It could also be viewed as unrelated information being added between samples during pretraining, complicating its categorization.

heading: 6 Analysis
text: Unsurprisingly, the CHEATING and VERBATIM contamination settings consistently outperform the BASELINE across both tasks. The in-domain settings’ consistent outperformance of the BASELINE underscores the advantages of exposure to related samples during pretraining (Krishna et al., 2023).
Far more concerning is that several approximate contamination settings outperform both the BASELINE and their respective in-domain settings, suggesting that the model in these settings benefits not only from seeing in-domain text but from unfairly leveraging prior knowledge of the test examples. In particular, the NOISED setting, which is generally not detectable with existing decontamination methods, produces scores inflated over BASELINE in all datasets, and scores more than one standard deviation above its corresponding in-domain setting in
several datasets. The MASKED setting generally performs around or worse than the BASELINE, possibly due to the more extreme formatting mismatch between this data and the test data. We expect that the MASKED setting may be encountered in the wild if a file of outputs for the dataset is in the pretraining data; the limited impact of this contamination on downstream performance is thus good news, though more investigation would be necessary to conclusively say MASKED contamination is not a concern.
For many of the contaminated settings and their corresponding in-domain settings, the effect of approximate contamination is not greater than affect of in-domain data seen during pretaining. However, research has shown that memorization in LLMs significantly grows as the size of the model increases (Carlini et al., 2023). The number of times a sample has been duplicated in the pretraining corpora has also been shown to increase a model’s memorization capabilities (Carlini et al., 2023; Golchin and Surdeanu, 2023).
Some behavior is task- or dataset-specific, emphasizing that there is no one-size-fits-all approach to data curation: the importance of removing each type of contamination from the pretraining corpus is at least partially linked to the specific task’s formatting. However, some types of approximate contamination do lead to inflated scores, emphasizing that considering a more broad definition of contamination when de-contaminating pretraining corpora is a worthwhile endeavor.

heading: 7 Conclusion
text: Our analysis highlights the importance of data format, with models performing better when pretraining data matches the evaluation format. We also observe task-specific effects, with certain contamination methods benefiting particular tasks more than others. Additionally, we find that some latestage pretraining contamination can actually be unhelpful to downstream performance, if it occurs in a substantially different format from the downstream task. Our findings underscore gaps in current decontamination practices, which primarily focus on full-dataset-level contamination and are often unable to detect approximate or noisy contamination.
We demonstrate that different types of contamination can have variable effects on model performance, highlighting the need for careful consideration during training and evaluation. With the
creation of our taxonomy, we hope to promote standardization regarding the definition and categories of contamination within the research community, facilitating clear communication and collaboration, while also enabling precise detection and mitigation of contamination in pretraining data. We recommend researchers decontaminating pretraining corpora for LLMs prioritize developing techniques that address noisy evaluation data, while also ensuring rigorous scrutiny to prevent any shuffled or interleaved evaluation data from inadvertently persisting in the pretraining data. It is not enough to merely remove instances of the full test dataset in the pretraining corpus; fragments or noised versions of the test set can also inflate performance. We hope our work inspires future work on detecting and mitigating specific types of contamination.

heading: 8 Limitations
text: Due to resource constraints, we only investigate the impact of encountering contaminated data towards the end of pretraining (i.e. with continued pretraining), rather than randomly throughout pretraining. This may introduce recency bias, influencing our findings. Additionally, our focus on a single language model limits the generalizability of our results. GPT-2 pretraining data is not publicly accessible so our results may only offer an approximation of contamination effects. Different model architectures, training procedures, and datasets may yield varying impacts of contamination. Conducting experiments on larger LLMs could potentially reveal more pronounced effects of contamination, as larger models have been shown to exhibit greater tendencies of memorization (Carlini et al., 2023). Further research involving multiple models and comprehensive evaluations is needed to establish more robust conclusions across diverse settings.

heading: Acknowledgements
text: The authors would like to thank Lori Levin for her early guidance and the anonymous reviewers for their thoughtful comments. This work was supported in part by grants from 3M, the Pittsburgh Supercomputing Center, and the National Science Foundation Graduate Research Fellowship under Grant No. DGE2140739.

heading: A Full results for Summarization Case Study
text: We present the full results of the summarization case study. For each setting and dataset, we have included a table of the Rouge metrics along with their standard deviations. The data is also presented through a series of bar charts for easier interpretability of the results for the reader. Standard deviations are measured over the results of the 3 models trained on random shuffles of the data.

heading: B Full results for Question Answering Case Study
text: We present the full results of the QA case study. For each setting and dataset, we have included a table of the exact match and f1 metrics along with their standard deviations. The data is also presented through a series of bar charts for easier interpretability of the results for the reader. Standard deviations are measured over the results of the 3 models trained on random shuffles of the data.

heading: C Examples for each contamination type
text: We provide examples of each of the functions from the different contamination types we are testing, applied to a sample from each dataset from the case studies.

heading: Future Work
text: We hope our work inspires future work on detecting and mitigating specific types of contamination