Concepts / Data Manipulation in AI Engineering

Data Manipulation in AI Engineering

In AI engineering, data manipulation is described as four activities: deduplication, tokenization, context retrieval, and quality control.

  • Programming

Two Labeling Jobs Compared

Imagine you are building a system and someone asks you to prepare training examples for it. For one task, each example is an email that needs a single label. For another task, each example is a request to write a long essay. Both jobs involve putting human judgment into data, but they do not feel equally hard. This article explains why, and it uses that difference to introduce the data work that AI engineering adds on top of traditional machine learning.

What do you think happens?

Which of these two jobs would take more effort to label well, labeling emails or labeling essay requests?

  • Labeling the emails

  • Labeling the essay requests

  • Both take the same effort

Reveal answer
Answer:

Labeling the essay requests takes more effort to label well.

Deciding whether an email is spam is a choice from a short menu, and two annotators who understand the task will usually agree. Judging an essay depends on many factors, so the annotator's decision is far less constrained.

Close-Ended Tasks and Fixed Labels

Definition

A close-ended query is one whose outputs are predefined. The possible answers form a known list before any data is collected.

The clearest illustration is spam classification. The model has only two possible outputs, spam and not spam, so the label set is fully known in advance. Most traditional machine learning use cases fall on this close-ended side. Because the answer space is short and fixed, the labeling task reduces to choosing one item from a small menu.

Open-Ended Tasks Without Predefined Outputs

Foundation models change this picture because they are open-ended. Their outputs are not limited to a short list of values. A request to write an essay can be answered in countless ways, and no fixed list of correct answers exists. This means the question of what counts as a correct label becomes much less obvious.

Spam or not spamtwo predefined outputsEssay requestno predefined outputsFixed label setknown before datacollectionMany acceptableanswersnot limited to a short listAnnotator selects onelabelchoice from a short menuAnnotator judgesqualitydepends on many factorsdefinesconstrainsproducesrequires
How the possible outputs of a close-ended task differ in structure from the possible outputs of an open-ended task, and why that changes labeling.

The comparison shows the structural difference. A close-ended task has a short, fixed set of acceptable labels, so the labeler's job is to pick one. An open-ended task has no such set, so the labeler's job becomes judging whether a response is good, which is a different kind of decision.

Why Annotators Diverge on Open-Ended Queries

Annotation requires an annotator to decide what the correct label is. For a close-ended task, that decision is a selection from a short menu, and two annotators who understand the task will usually land on the same choice. For an open-ended task, the annotator must produce or judge something whose quality depends on many factors, so the decision is far less constrained. Two careful annotators can reasonably reach different judgments, which is why the source concludes that data annotation is a much bigger challenge for AI engineering.

Worked example

Labeling an essay request

An annotator is asked to label whether a model's response to a request for a long essay is acceptable.

  1. 1
    Read the request

    The request asks for a long essay on an open-ended topic, so many different essays would satisfy it.

  2. 2
    Check for a fixed answer

    There is no short list of predefined outputs to choose from, so the annotator cannot simply select a label.

  3. 3
    Judge against many factors

    The annotator must weigh qualities such as relevance, organization, and completeness, each of which involves judgment.

  4. 4
    Compare with another annotator

    A second annotator may weigh those factors differently and reach a different verdict, and both verdicts may be defensible.

Result

The label is hard to make consistent because the decision depends on judgment rather than on selecting from a known menu.

Tabular Versus Unstructured Data

The source identifies a second difference between the two engineering settings: the kind of data each one works with. Traditional ML engineering works more with tabular data, meaning data organized into rows and columns with a defined structure. Foundation models work with unstructured data, such as free-form text and other content that does not arrive in a fixed grid of fields.

Because unstructured data has no built-in schema, the steps used to prepare it look different. A table already tells you which column holds which field. Free-form text does not, so the data work has to be designed for content whose structure is not given in advance. This is the reason AI engineering adds its own set of data manipulation activities.

The Four Data Manipulation Activities

In AI engineering, data manipulation is described as four activities: deduplication, tokenization, context retrieval, and quality control. The map below shows how these pieces relate to the single umbrella idea. It shows the four activities as parts of one category and does not claim a fixed order among them.

Data manipulationin AI engineeringDeduplicationdeals with repeated dataRemoving sensitiveinformationTokenizationconverts text into modelunitsRemoving toxic dataContext retrievalbrings supporting materialto the modelQuality controlthe broadest of the fourincludesincludesincludesincludesresponsibilityresponsibility
The four activities that make up data manipulation, with quality control's two specific responsibilities shown beneath it.

Deduplication Before and After

To see what deduplication changes, consider a small illustrative dataset of support records. Two records contain almost the same text, differing only by punctuation. Removing the near-duplicate leaves a dataset where each distinct record appears once.

Reset your passwordtodayrecord 1Reset your passwordtodayrecord 1Reset your passwordtoday!record 2, near-duplicateRefund policy summaryrecord 3Refund policy summaryrecord 3
What the illustrative dataset looks like before and after near-duplicate records are removed.

In the before state, the password reminder appears twice. In the after state, it appears once and the refund summary is untouched. The point is that deduplication changes the dataset's contents while leaving the distinct information in place.

Common Mistakes When Reasoning About Labels

  • Common mistake

    Assuming every AI labeling task is as easy as spam classification

    What it looks like

    Treating a request for an essay the same way as an email that needs one label

    Why it fails

    Spam classification has a fixed set of two outputs, but open-ended outputs have no predefined list, so the labeling decision is far less constrained.

    Do this instead

    Ask first whether the outputs are predefined. If they are not, plan for more effort and for disagreement between annotators.

  • Common mistake

    Thinking that a disagreement between annotators means one of them is simply wrong

    What it looks like

    Two annotators judge the same essay response differently and one label is discarded

    Why it fails

    Open-ended quality depends on many factors, so two careful judgments can both be defensible.

    Do this instead

    Treat divergent labels as a signal about the task's ambiguity and design the labeling process around it.

  • Common mistake

    Treating deduplication, tokenization, context retrieval, and quality control as a fixed sequence when the source does not claim an order

Quality Control Beyond Accuracy

Because quality control has these specific responsibilities, the quality question for an open-ended dataset is wider than whether an annotator picked the right option. It also asks whether the data should be in the dataset at all.

Practice: Sorting Labeling Tasks

EASY

For each of these tasks, decide whether it is close-ended or open-ended, and explain how that choice affects how hard it is to label consistently: (1) sorting an email as spam or not spam, (2) writing a long essay in response to a prompt, (3) deciding whether a sentence contains sensitive information.

Hints
  • Ask whether the possible outputs are a short, predefined list.
  • Close-ended tasks usually have a fixed label set, so annotators usually select from a menu.
  • Task 3 is about the quality control activity, which the source names as including removal of sensitive information.

Key Takeaways

  • Close-ended queries have predefined outputs, such as spam or not spam, so their labels can be selected from a short, known menu.
  • Open-ended queries have no predefined outputs, so annotating them is much harder and annotators' judgments can diverge.
  • Traditional ML engineering works more with tabular data, while foundation models work with unstructured data, which changes the preparation steps.
  • AI engineering data manipulation covers deduplication, tokenization, context retrieval, and quality control, including removing sensitive information and toxic data.

Related concepts

More concepts starting with D