Concepts / Data Quality Checks Before Training

Data Quality Checks Before Training

High-quality data is judged against the task a model is being trained to perform, and a smaller set of carefully prepared examples can outperform a larger noisy one.

  • Programming

Two Datasets, One Question

Imagine you are preparing data to train a model. A natural instinct is to collect as much of it as you can, on the reasoning that more examples means more learning. Before you commit to that plan, consider a question the source material raises directly: which of the following would you expect to train a better model?

What do you think happens?

Which training set is more likely to produce the better model: a curated set of about 1,000 carefully prepared examples, or a set of several hundred thousand examples full of noise?

  • The several hundred thousand noisy examples, because volume wins

  • The curated set of about 1,000 examples, because careful preparation can outweigh raw size

  • They would perform identically, because the model only sees the number of examples

Reveal answer
Answer:

The curated set can win. The source reports that the creators of the Yi model family found around 10,000 carefully crafted instructions were superior to several hundred thousand noisy ones.

Noise, in the source's sense, is material that is irrelevant to the job or that contradicts itself. A large pile of noisy examples gives the model a lot of conflicting signal. A smaller set that has been prepared carefully gives it cleaner signal to learn from. The point is not that small is always better, but that quality can matter more than quantity.

This lesson is about how to judge data before training begins. The short answer from the source is that data is high quality when it helps you do your job efficiently and reliably. The rest of the lesson turns that idea into a concrete checklist and then shows how to apply it to individual records.

Quality Depends on the Task

The first idea to hold onto is that quality is not a fixed property of a dataset. A dataset is good or bad only relative to what the model is supposed to do. The same collection of documents can be the right material for one project and useless for another.

Task A: answerlegal questionstoday19th-century legaldatasetLow relevanceTask B: study the19th-century legalsystemHigh relevancedefines the purposedefines the purposejudged for task Ajudged for task B
The same 19th-century legal dataset is judged differently depending on which task the model must perform.

Read the diagram as a dependency. The task comes first, and the judgment of quality is derived from it. The dataset does not carry a quality score around with it. Instead, the question 'is this good?' always has to be followed by 'good for what?'. The source's legal example makes this concrete. If the model's task is to answer legal questions as the law stands today, a legal dataset from the 19th century may not be relevant. If the model's task is instead to describe the legal system of the 19th century, that same dataset becomes highly relevant.

Following One Dataset Through the Checks

Quality checks are easiest to understand as a gate that a dataset passes through before it reaches training. The source lists six characteristics but does not prescribe an order for checking them. The sequence in the diagram below is one reasonable way to organize the work, and each stage asks the same kind of question: does this dataset meet this requirement, or does it need to be repaired or rejected?

Raw datasetRelevant to task?Labels aligned withtask?Labels consistent?Formatting clean?Duplicationtolerable?Policy compliant?Training dataRepair or rejectcheckyesnoyesnoyesnoyesnoyesnoyesno
A raw dataset moves through six checks. A failure at any check sends the data back for repair or rejects it; only data that passes every check reaches training.

Notice that the gate is not only about throwing data away. Some failures, such as formatting noise, can be fixed by cleaning the text, while others, such as material that is simply off-task, usually mean the record should be excluded. The source also reminds us that the checks are not an afterthought. Before creating data, you should think about what each characteristic means for your project, because the techniques used to produce data are aimed at producing exactly these qualities.

The Six Characteristics

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 source also notes that some use cases carry extra requirements beyond these six. Treat the six as a default checklist to start from, then add task-specific checks when the project calls for them.

RelevanceOff-task materialAlignmentLabels that miss thepurposeConsistencySame label, differentjudgmentsCorrect formattingHTML tags and straywhitespaceUniquenessRepeated examplesComplianceProhibited personaldataviolated whenviolated whenviolated whenviolated whenviolated whenviolated when
Each of the six characteristics has a typical failure. Reading across shows which problem a learner should look for when a record seems wrong.
CharacteristicQuestion it asksTypical violation
RelevantDoes this example belong to the task at hand?Material that does not bear on what the model must do
Aligned with task requirementsDo the annotations match what the task requires?Labels that are correct but do not fit the purpose, such as a long answer where concision was required
ConsistentDo the labels hold steady across examples and annotators?Identical labels that hide very different judgments
Correctly formattedDoes every example follow the expected format?HTML tags, trailing whitespace, stray new lines, inconsistent casing, mixed numerical formats
UniqueAre the examples sufficiently unique from one another?Duplicates that skew what the model learns or leak into training
CompliantDoes the data follow all relevant internal and external policies?Personally identifiable information in data that must not contain it

The six characteristics, the question each one asks, and a typical violation

Diagnosing a Bad Record

Now trace a single record through the checks. The example below is generated for illustration, and it follows the kind of scraped product review the source describes.

Worked example

Finding the violated characteristic in a scraped review

A scraped record contains the review text '<p> Great blender, works well! </p>' with the rating written as '4.0', and another record in the same batch stores its rating as 4 and its text in all capitals. Which characteristics are violated, and what does a corrected record look like?

  1. 1
    Check the text against the content

    The HTML tags <p> and </p> are not part of what the review says. They are redundant formatting tokens, so this is a formatting violation under the correctly formatted characteristic.

  2. 2
    Look for invisible formatting problems

    The extra spaces before and after the sentence are trailing or leading whitespace. A human reader would not notice them, but the model sees them as differences, so this is also a formatting violation.

  3. 3
    Compare numerical formats across records

    One record stores the rating as 4.0 and another as 4. The values are the same, but the formats are mixed. Mixed numerical formats count as a formatting problem, so the batch needs one agreed representation.

  4. 4
    Compare casing across records

    A review written in all capitals differs in casing from the rest of the batch. Inconsistent casing is also a formatting problem, so the text should be normalized to the casing the dataset expects.

  5. 5
    Write the corrected record

    Remove the tags, trim the whitespace, and store the rating in one consistent numerical format. The corrected text is 'Great blender, works well!' with a rating of 4.0 in every record.

Result

The problems are all in the correctly formatted characteristic. The content of the review is untouched; only the surrounding noise is removed. The record has not changed in meaning, but it now matches the format the model is expected to work with.

Notice what this example did not require. The review's meaning did not change, and no record had to be deleted. Some quality problems are repaired, not discarded. Other problems, such as an off-task document or personally identifiable information in a dataset that must not contain it, may require removing the record entirely.

Misreadings of Data Quality

Several readings of data quality sound reasonable but lead to poor decisions. The most important is the instinct the source warns about first: collecting as much data as possible.

  • Common mistake

    Assuming more data is always better

    What it looks like

    A team adds several hundred thousand scraped examples to a training set that already has noisy and off-task material, expecting the model to improve.

    Why it fails

    The source reports that a modest collection of well-prepared examples can outperform a very large collection full of noise. Noise here means material irrelevant to the job or material that contradicts itself. Adding more noisy rows adds more conflicting signal for the model to sort through.

    Do this instead

    Judge additional rows against the six characteristics before adding them. A smaller, carefully prepared set can be the better choice.

  • Common mistake

    Treating quality as a fixed property of the dataset

    What it looks like

    A legal dataset from the 19th century is declared high quality, and then used for a task about current law.

    Why it fails

    Relevance is relative to the task. The same document can be irrelevant for one purpose and highly relevant for another.

    Do this instead

    State the task first, then judge the data against it.

  • Common mistake

    Confusing accuracy with alignment

    What it looks like

    A correct but very long answer is kept as the label for a question where the task asks for concise replies.

    Why it fails

    The source chose the word aligned instead of accurate or correct because a response can be true and still not be what the task requires.

    Do this instead

    Check each annotation against the purpose the task specifies, not only against whether it is true.

  • Common mistake

    Assuming that identical labels mean identical judgments

    What it looks like

    Two essays both receive a 4 on a 1 to 5 scale, but the annotators used different unstated standards.

    Why it fails

    When an annotation scheme is vague, identical labels can hide very different judgments, which confuses the model.

    Do this instead

    Write an annotation guideline so that the same label means the same judgment to every annotator, and test consistency by having two annotators label the same example.

  • Common mistake

    Dismissing formatting because humans can read the text

    What it looks like

    Trailing spaces and HTML tags are left in place because a reader would not notice them.

    Why it fails

    None of these changes the meaning to a human, but the model sees each variation as a difference it must account for, and redundant formatting tokens can interfere with learning.

    Do this instead

    Strip tags, trim whitespace, and normalize casing and numerical formats before the text becomes training data.

  • Common mistake

    Treating zero duplication as the only acceptable level of uniqueness

Where the Checklist Has Limits

The source also reports a tradeoff in the LIMA project. Its team 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 notes that a model trained on that few examples was not as robust as product-grade models. A small, curated dataset can therefore be a strong choice for some goals while still falling short on others, and the checklist does not remove that tradeoff.

Checking Your Own Data

Work through this scenario before reading the summary. A team is building a model to answer short customer questions about a software product. Their training file contains the following three records, shown as they were stored.

MEDIUM

Record 1: a question about resetting a password, with an answer that is a full chapter copied from an unrelated printed manual. Record 2: a question about resetting a password, with the answer '<b>Use the Forgot Password link</b>'. Record 3: the same question and answer as Record 2, appearing a second time. For each record, name the characteristic being violated and describe what a corrected version would look like. Then decide whether the three records together are a problem, and explain your reasoning.

Hints
  • Ask first whether the answer matches the purpose of a short customer question. That is an alignment question.
  • The HTML bold tags in Record 2 are a formatting issue, but the tags alone do not change the meaning of the answer.
  • Record 3 is a duplicate. Consider whether the level of duplication is tolerable for this use case, not only whether it is zero.

Summary of the Checks

The checks above can be used together as a sequence of questions. Each one returns to the task that the model must perform, because quality is judged against that task.

At a glance

  • Data quality is relative to the task. The same example can be relevant and high quality for one model task and irrelevant for another.
  • The six default characteristics are relevance, alignment with task requirements, consistency, correct formatting, uniqueness, and compliance. Add task-specific checks when a project needs them.
  • A specific violation points to a specific fix: off-task material is excluded, misfit labels are rewritten, inconsistent labels are addressed with an annotation guideline, formatting noise is stripped, duplicates are limited to a tolerable level, and policy-breaking data such as PII is removed.
  • More data is not automatically better. A modest, carefully prepared set can outperform a very large set full of noise, although a small set may not be as robust as larger, product-grade training data.

Related concepts

More concepts starting with D