Removing Duplicates and Contamination from Datasets
Uniqueness means the examples in a dataset are sufficiently unique from one another.
Why More Data Is Not Automatically Better
A natural instinct when training a model is to collect as much data as possible, on the reasoning that more examples means more learning. The evidence reported in the source material points somewhere different. A modest collection of well-prepared examples can outperform a very large collection that is full of noise. In this context, noise means material that is irrelevant to the job the model must do, or material that contradicts itself. This article traces how a dataset is judged, step by step, and how duplicates and contamination are removed along the way.
What do you think happens?
Which training set would you expect to produce the better instruction-following model: about 500,000 instructions with many noisy or contradictory entries, or about 10,000 carefully crafted instructions?
Reveal answer
The 10,000 carefully crafted instructions. The creators of the Yi model family reported that around 10,000 carefully crafted instructions were superior to several hundred thousand noisy ones.
The source reports this result as the Yi creators' finding. The lesson is that the value of each example depends on whether it is relevant, consistent, and well formatted, not only on how many examples exist.
Quality Is Measured Against a Task
High-quality data is judged against the task a model is being trained to perform. Quality is not a single number that a dataset carries on its own. Different people will disagree about the details depending on what they are building, so the practical question is always what good data looks like for this particular job. The source material does give a common starting checklist of six characteristics, which are covered in the next section.
The same example can be high quality for one task and low quality for another. The source illustrates this with legal material. If the task is to answer legal questions as they apply today, a legal dataset from the 19th century might not be relevant. If the task is instead about the legal system of the 19th century, that same dataset becomes highly relevant. Relevance is therefore not a property a document has in isolation. A document is relevant or irrelevant only in relation to what the model is supposed to do.
The Six Characteristics Checklist
The source gives a common checklist: data can be considered high quality if it has six characteristics. It should be relevant, aligned with task requirements, consistent, correctly formatted, unique, and compliant. The table below summarizes the question each characteristic asks of a dataset.
| Characteristic | Question it asks of each example |
|---|---|
| Relevant | Does this example belong to the task at hand? |
| Aligned with task requirements | Do the annotations match what the task requires? |
| Consistent | Do the same kinds of examples get the same kinds of labels, even across annotators? |
| Correctly formatted | Does every example follow the format the model is expected to work with? |
| Unique | Are the examples sufficiently different from one another for the project's needs? |
| Compliant | Does the data follow all relevant internal and external policies, including laws and regulations? |
The six default characteristics of high-quality training data
Tracing One Scraped Review Through Cleaning
Consider the source's example of scraped product reviews. Those pages often carry HTML tags around the review text. The tags are not part of what the review says, so they should be stripped before the text becomes training data. The worked example below follows a single raw record through the cleaning steps. The record and its copy are invented here for illustration, but the cleaning rules come directly from the source.
Cleaning a scraped review and its duplicate
Two copies of one scraped review arrive as raw text: '<b>Great Blender!</b> ' on the first page, and the same review again on a second page. Prepare them for training so that the formatting is correct and the dataset keeps only the needed copy.
- 1Strip the HTML tags
The b tags are markup, not review content. Removing them leaves the text the reviewer actually wrote. This addresses correct formatting.
- 2Normalize whitespace
The triple space inside the review and the trailing spaces are stray whitespace. They do not change the meaning for a human reader, but a model sees each variation as a difference to account for.
- 3Apply one casing convention
Choose a single casing rule for the whole dataset, for example lowercase, and apply it everywhere. Inconsistent casing is a formatting problem for the same reason as stray whitespace.
- 4Remove the duplicate
After cleaning, both copies are identical. Uniqueness is judged as a level the project can tolerate, so keeping one copy and dropping the repeat is the correction this example calls for.
One record, 'great blender!', with no tags, no stray spaces, one casing convention, and no repeat. Each step fixed a specific violation of formatting or uniqueness.
Alignment and Consistency in Labels
Alignment concerns the annotations, meaning the labels or target answers attached to each example. The principle is that annotations should match what the task requires. The source gives contrasting cases. If the task requires factual consistency, the annotations should be factually correct. If the task requires creativity, the annotations should be creative. If the task asks for a score along with a justification, each annotation should contain both. If the task asks for concise answers, the annotations should be concise.
The source deliberately uses the word aligned rather than accurate or correct. An accurate or correct response might not be what a user wants. A reply that is technically right but far too long for a quick question has not met the requirement. Alignment means matching the purpose of the task, not just being true.
Consistency asks whether the labels hold steady. Two properties matter. First, the same kind of example should receive the same kind of label. Second, different annotators working on the same example should produce labels that are not far apart. The source gives a direct test: if two annotators annotate the same example, their annotations should not be too different.
The source raises a practical question using essay scoring on a scale from 1 to 5. If two essays both receive a 4, are they really of the same quality? When an annotation scheme is vague, identical labels can hide very different judgments. The source states the consequence plainly: inconsistent annotations can confuse the model and make it harder to learn. The remedy it points to is a good annotation guideline, which gives annotators a shared standard so that the same label means the same judgment. Such a guideline is essential for annotations that are both aligned with the task and consistent with each other.
Duplicates and Contamination Between Splits
Uniqueness means the examples in a dataset are sufficiently unique from one another. The source is careful with the word sufficiently. Duplications can introduce biases and cause data contamination during training, but specific use cases can tolerate different levels of duplication. Uniqueness is therefore not a requirement of zero repeats. It is a level you decide on based on what the project can tolerate.
The reasoning behind the concern is that a repeated example carries extra weight. If one item appears many times, the model sees its pattern more often than the pattern deserves, which can skew what it learns. Contamination is a related danger: material that should be kept separate from the data used to judge the model can leak into training. Duplicates are one common route for that leak. The diagram below traces how an evaluation example can end up in training data through a repeated copy.
In the diagram, the evaluation example is meant to stay in the evaluation split. A second copy collected from the scraped pool then flows into the training split, so the model has effectively seen the material it will later be judged on. Removing that repeat is what keeps the two sets separate. Deciding how much duplication to allow is a judgment call tied to the goal of the model.
Formatting Noise That Humans Overlook
Correct formatting means that every example follows the format the model is expected to work with. The source adds a specific claim: redundant formatting tokens can interfere with the model's learning, so they should be removed. HTML tags wrapped around review text are the obvious case, but the source also warns about less visible issues. Trailing whitespace, stray new lines, inconsistent casing, and mixed numerical formats all count as formatting problems.
Compliance With Policies and Law
The final characteristic is compliance. Data should comply with all relevant internal and external policies, and the source explicitly includes laws and regulations in that category. The source's example is direct: if you are not allowed to use personally identifiable information to train your models, then your data should not contain any PII at all.
A team collects support chat logs to train a customer-help model. The project policy forbids personally identifiable information in training data. A log that includes a customer's full name and phone number fails the compliance characteristic, even if the question in the log is perfectly relevant and well formatted. The corrected version removes the identifying details and keeps the question and answer, so the example still teaches the task.
Small Curated Sets Versus Large Noisy Ones
The source describes a project called LIMA, which fine-tuned a 65-billion-parameter Llama model on 1,000 carefully curated prompts and responses. Human annotators judged its answers equivalent to or strictly better than GPT-4's answers in 43 percent of cases. The same source also notes a tradeoff: a model trained on that few examples was not as robust as product-grade models. A small, curated set can therefore be very effective for some goals while still falling short on others.
Common Misreadings of Data Quality
Common mistake Assuming more data is always better
What it looks likeAdding several hundred thousand noisy instructions to a set of 10,000 carefully crafted ones.
Why it failsThe source reports that a modest set of well-prepared examples can outperform a very large noisy one. Each noisy example can teach the wrong pattern.
Do this insteadJudge each added example against the task's characteristics before adding it, and treat noise as a cost rather than free volume.
Common mistake Treating relevance as a fixed property of a document
What it looks likeKeeping a 19th-century legal dataset for a model that must answer today's legal questions because it is legal text.
Why it failsRelevance is defined only in relation to what the model is supposed to do.
Do this insteadWrite down the task first, then check each document against it.
Common mistake Reading aligned as just another word for accurate
What it looks likeA factually correct but very long answer used as the annotation for a quick-question task.
Why it failsThe source chose aligned on purpose, because an accurate response might not be what the user wants.
Do this insteadCheck that the annotation matches the purpose, including length, style, and format the task calls for.
Common mistake Believing uniqueness means zero repeats
What it looks likeDeleting every near-repeat from a project whose use case tolerates some duplication.
Why it failsThe source says specific use cases can tolerate different levels of duplication.
Do this insteadDecide an acceptable duplication level based on the project, and remove repeats that go beyond it, especially those that create contamination.
Common mistake Thinking formatting problems matter only when they change meaning for a human reader
Common mistake Assuming the six characteristics are a complete and final list for every project
Practice Spotting Violations
For each dataset problem below, name the characteristic being violated and describe what a corrected version would look like. (a) A review of a blender is stored as '<p>Works great</p>' while others are stored as plain text. (b) A set meant to test a model is also present in the training split. (c) A creative-writing task has annotations that are only short factual summaries. (d) Two annotators label the same essay as 4 and 1 on a 1 to 5 scale with no shared guideline.
Hints
- Part (a) is about formatting: HTML tags are not part of what the review says.
- Part (b) is about contamination, which the source connects to duplicates leaking across splits.
- Part (c) is about alignment: the annotations must match what the task requires, here creativity.
- Part (d) is about consistency: the source says annotations from the same example should not be too far apart, and a shared guideline is the remedy.
Key Takeaways
- High-quality data is judged against the task a model is being trained to perform, not against an absolute standard.
- The six default characteristics are relevance, alignment with task requirements, consistency, correct formatting, uniqueness, and compliance with policies, and projects may add task-specific checks.
- Uniqueness is a tolerance decided per project, and repeated examples can skew learning and leak evaluation material into training.
- A smaller set of carefully prepared examples can outperform a larger noisy one, but a small curated set may still fall short on robustness.