Concepts / Quality Control for Training Data

Quality Control for Training Data

Dataset engineering covers curating, generating, and annotating the data used to train and adapt AI models.

  • Programming

Why Training Data Sets the Ceiling

A model can only learn from the examples it is shown. The quality and shape of those examples set a ceiling on what the model can do. Dataset engineering is the discipline that handles this material. It asks where training and adaptation data will come from, how that data should be prepared, and how each example gets its label or target. Before you can reason about a model's behavior, you need to know what went into it.

What do you think happens?

Which is easier to annotate: a message that must be labeled spam or not spam, or a free-form essay that must be judged?

  • The spam label

  • The essay

Reveal answer
Answer:

The spam label

A spam label is chosen from a short, fixed list, so two careful annotators will usually agree. An essay has to be judged on many dimensions at once, such as accuracy, completeness, tone, and appropriateness. The sections below explain this difference.

Curating, Generating, and Annotating

Dataset engineering covers three core activities. They often appear together in one project, so it helps to see how they connect before looking at each one separately.

Definition

Curating means selecting and organizing data that already exists so that it is suitable for the task.

Definition

Generating means producing new data when suitable examples do not exist in sufficient quantity.

Definition

Annotating means attaching labels, targets, or judgments to data so that a model or an evaluator can learn from it.

Dataset engineeringdata for AI modelsCuratingselect and organizeexisting dataTraining andadaptationmodel learns from the dataGeneratingproduce new data whenexamples are scarceAnnotatingattach labels, targets,judgmentsincludesincludesincludessupplies datasupplies datasupplies labels
How do curating, generating, and annotating relate to each other, and which of them feed into training or adapting the model?

The diagram shows that all three activities lead toward the same destination: the data a model uses to learn or adapt. Curating decides which existing material is worth keeping, generating fills gaps where examples are missing, and annotating turns raw examples into examples with a target the model can learn from.

Tracing One Collection Through the Three Activities

Worked example

Preparing Return-Policy Training Data

A team wants a model that answers customer questions about product returns. It has 200 existing support emails, but only a few of them ask about exchanges. Use curating, generating, and annotating to prepare the training data.

  1. 1
    Curate the existing emails

    Select the emails that concern returns and exchanges, and organize them by topic so the collection suits the task. Suppose 160 remain after removing unrelated messages.

  2. 2
    Generate the missing examples

    Exchange questions are underrepresented, so the team writes additional variants of exchange questions. Generating is used here because suitable examples do not exist in sufficient quantity.

  3. 3
    Annotate every example

    Each example receives a target, such as the correct policy category or a reference answer. Annotating attaches the judgment the model needs to learn from the example.

Result

The team now has one collection that combines curated originals, generated variants, and annotations, ready for the processes described in later sections.

Close-Ended and Open-Ended Tasks

The difference that drives most of the extra work in AI engineering is the shape of the answer a task allows. A close-ended task chooses from predefined values. In traditional machine learning, most use cases are close-ended. Spam classification is the standard illustration: the output is either spam or not spam, and nothing else is possible.

Foundation models are open-ended. Their outputs are not restricted to a list fixed in advance, so a response might be a paragraph, a summary, or a piece of code. The number of acceptable answers is no longer small and fixed, which changes what the data work must handle.

Fixed set of valueschosen from predefined listNo fixed list ofoutputsnot restricted in advanceSpam or not spamthe only possible outputsParagraph, summary,or codemany possible responsesShort list to choosefromannotation is a simplechoiceMany judgmentdimensionsaccuracy, completeness,toneexampleannotationexampleannotation
How do close-ended and open-ended queries differ in the number of acceptable answers, and why does that make annotating open-ended queries harder?

Why Open-Ended Annotation Is Harder

The source makes a direct comparison: judging whether an email is spam is much easier than writing an essay. The same asymmetry appears in annotation. Labeling a close-ended example means choosing from a short list, and two careful annotators will usually agree.

Annotating an open-ended example means deciding whether a free-form answer is good. That judgment involves many dimensions at once, such as accuracy, completeness, tone, and appropriateness. An annotator must weigh several qualities together rather than pick one value from a list, which is why annotating open-ended queries is described as a much bigger challenge for AI engineering.

Structured Tables Versus Unstructured Data

A second difference concerns the form the data takes. Traditional machine learning engineering works more often with tabular data, organized into rows and columns with a defined set of fields. Foundation models work with unstructured data such as raw text, images, or audio, where there is no fixed grid of fields to rely on. AI engineering works more with unstructured data than the tabular data typical of traditional machine learning.

AspectTraditional machine learningAI engineering with foundation models
Typical taskClose-ended, choosing among predefined valuesOpen-ended, with outputs not fixed in advance
Example outputSpam or not spamA paragraph, a summary, or a piece of code
Data formTabular, rows and columns with defined fieldsUnstructured, such as raw text, images, or audio
PreparationWorks within a fixed grid of fieldsRequires different tools and different checks
Annotation difficultyUsually a short choice, with high agreementJudgment across many dimensions, much harder

How the output type and data format differ between the two fields

Four Data Manipulation Processes

Data manipulation covers the processes that turn collected data into something a model can use well. The central work in AI engineering is deduplication, tokenization, context retrieval, and quality control. Each addresses a different kind of problem, so it helps to hold them as separate concerns even though they all serve the same purpose: making collected data usable and trustworthy for a model.

Definition

Deduplication removes repeated or near-identical training examples from the collection.

Definition

Tokenization converts text into the token units that the model reads.

Definition

Context retrieval brings in related material for a record. This article names it as one of the four core processes without going into its mechanics.

Definition

Quality control checks the data for problems and removes sensitive information and toxic data.

Collected recordraw text, image, or audioDeduplicationremove repeated copiesTokenizationtext into model token unitsContext retrievalbring in related materialQuality controlremove sensitive and toxicdataTraining-ready datausable and trustworthyentersthenthenthenproduces
In what order do the data manipulation steps run, and how does a single record move from raw input through each step to training-ready data? The order shown is one illustrative run, because the source does not fix a required sequence.

Tracing a Record Through the Pipeline

Follow one scraped customer chat record through the processes. The record starts as raw text, and each step changes what the collection holds. The walkthrough uses the illustrative order from the diagram, since the source does not require one fixed sequence.

Worked example

One Chat Record Moving Through Data Manipulation

The collection contains two identical copies of a chat in which a customer asks about a late delivery. One copy includes the customer's full home address, and the agent's reply contains an insulting phrase. Trace how the processes treat this record.

  1. 1
    Deduplication

    The two identical copies are reduced to one. Keeping both would give the model the same example twice.

  2. 2
    Tokenization

    The remaining text is converted into the token units the model reads, so the record is in the form the model processes.

  3. 3
    Context retrieval

    Related material for the delivery question is brought in alongside the record, as the process requires.

  4. 4
    Quality control

    The home address is sensitive information and is removed. The insulting phrase is toxic and is removed as well. Both removals protect users and the model's later behavior.

Result

One cleaned, tokenized record remains in the collection, with no duplicate copy and no sensitive or toxic content.

The table below shows the effect of deduplication alone on a small collection. Only the exact repeats are removed, and each distinct record stays.

RecordBefore deduplicationAfter deduplication
Chat A, delivery questionPresent, copy 1Kept once
Chat A, delivery questionPresent, copy 2Removed as a repeat
Chat B, refund questionPresentKept
Chat C, exchange questionPresent, copy 1Kept once
Chat C, exchange questionPresent, copy 2Removed as a repeat

A small collection before and after deduplication, with repeated copies removed and distinct records kept

Quality Control and Sensitive Data

Quality control is broader than the other three processes, because it explicitly includes removing sensitive information and removing toxic data. Those removals protect users and the model's later behavior, which is why they belong in the same family of work as the other steps.

Mistakes Beginners Make

  • Common mistake

    Assuming annotating open-ended outputs is as easy as annotating spam labels

    What it looks like

    Labeling a free-form answer as good or bad with no further criteria

    Why it fails

    Open-ended judgments involve many dimensions at once, such as accuracy, completeness, tone, and appropriateness, so agreement is much harder to reach.

    Do this instead

    Define the dimensions the annotators should judge before labeling begins.

  • Common mistake

    Treating unstructured data like a table

    What it looks like

    Applying row-and-column checks to raw chat text or audio

    Why it fails

    Unstructured data has no fixed grid of fields, so it requires different tools and different checks.

    Do this instead

    Choose tools and checks that suit raw text, images, or audio.

  • Common mistake

    Assuming curation alone is enough

    What it looks like

    Using only the existing emails when exchange questions are rare

    Why it fails

    Curating selects existing data. Generating is the activity used when suitable examples do not exist in sufficient quantity.

    Do this instead

    Check coverage after curating, and generate additional examples where gaps remain.

  • Common mistake

    Keeping repeated copies because they look valid

    What it looks like

    Keeping two identical chat records in the collection

    Why it fails

    Repeated examples are exactly what deduplication targets, and keeping them adds no new information.

    Do this instead

    Deduplicate so that each repeated or near-identical example is kept only once.

  • Common mistake

    Believing quality control only checks formatting, when it also removes sensitive and toxic data

Practice: Plan the Processes

MEDIUM

A team has 1,000 scraped product reviews. Many are near-identical copies, some mention customer names, and a few contain insults. The team also needs each review labeled as positive or negative. Which processes apply to this collection, which activity does the labeling belong to, and in what order would you run the steps? Explain why the labeling task is simpler than annotating open-ended answers.

Hints
  • Look for the activity that attaches a judgment to each example and decide whether it is close-ended.
  • Repeated copies point to deduplication, and names and insults point to quality control.
  • The source does not fix a required order, so justify whatever sequence you choose.

Key Takeaways

  1. 1
    Dataset engineering covers curating existing data, generating new data when examples are scarce, and annotating data with labels, targets, or judgments.
  2. 2
    Close-ended tasks choose from predefined values, while open-ended foundation model tasks do not, which makes annotating open-ended queries much harder.
  3. 3
    AI engineering works more with unstructured data than the tabular data typical of traditional machine learning.
  4. 4
    Data manipulation centers on deduplication, tokenization, context retrieval, and quality control, which includes removing sensitive and toxic data. The source does not fix their order.

At a glance

  • Dataset engineering covers curating, generating, and annotating the data used to train and adapt AI models.
  • Close-ended tasks choose from predefined values, while open-ended foundation model tasks produce outputs not fixed in advance, which makes annotating open-ended queries much harder.
  • AI engineering works with unstructured data such as text, images, and audio, unlike the tabular data typical of traditional machine learning.
  • Data manipulation centers on deduplication, tokenization, context retrieval, and quality control, and quality control includes removing sensitive and toxic data.

Related concepts

More concepts starting with Q