Preparing Unstructured Data for Models
Dataset engineering covers curating, generating, and annotating the data used to train and adapt AI models.
Why the Examples Set 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 takes care of 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 harder to annotate reliably: deciding whether an email is spam, or deciding whether a long essay is good?
Reveal answer
Deciding whether a long essay is good is harder.
Labeling spam means choosing from a short, fixed list, and two careful annotators will usually agree. Judging an essay means weighing many dimensions at once, such as accuracy, completeness, tone, and appropriateness. The source makes the same point: judging spam is much easier than writing an essay, and the same asymmetry shows up in annotation.
Following One Dataset from Raw Material to Labels
Before looking at the definitions, follow a single project through the work. The scenario below is an illustrative example written for this article to show how the three core activities often appear together in one project.
Building a Support-Reply Training Set
A team wants to adapt a model to draft replies to customer support messages. They already have a folder of past support conversations, but very few examples cover billing disputes.
- 1Curate the existing material
Select and organize the past conversations so they suit the task. Remove material that is off-topic or unsuitable, and keep the rest in a clear structure.
- 2Generate what is missing
Because suitable billing-dispute examples do not exist in sufficient quantity, produce new examples that cover that case, such as variants of existing disputes written in different styles.
- 3Annotate the full set
Attach a judgment or target to each example so that a model or an evaluator can learn from it. For a free-form reply, this means deciding whether the reply is accurate, complete, and appropriate in tone.
The team ends with one organized dataset that combines curated, generated, and annotated examples. This is the pattern the source describes: curating, generating, and annotating often happen together in one project.
The Three Activities of Dataset Engineering
Curating means selecting and organizing data that already exists so that it is suitable for the task. Generating means producing new data when suitable examples do not exist in sufficient quantity. Annotating means attaching labels, targets, or judgments to data so that a model or an evaluator can learn from it.
Together these three activities are the core of dataset engineering. They are not separate steps that never meet. A project might curate a collection of raw material, generate additional variants of it, and then annotate the full set, as the support-reply example above did. The diagram below shows how the three activities sit under the one term.
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. In traditional machine learning, most use cases are close-ended: the model must choose among a fixed set of predefined values. Spam classification is the standard illustration, because 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 diagram below sets the two kinds of task side by side.
Annotating a close-ended example means choosing from a short list. Annotating an open-ended example means deciding whether a free-form answer is good, and that decision involves several dimensions at once. This is why the source calls annotation a much bigger challenge for AI engineering.
Tracing Data Through Manipulation
Data manipulation covers the processes that turn collected data into something a model can use well. The source names four central processes: deduplication, tokenization, context retrieval, and quality control. Quality control in turn includes removing sensitive information and removing toxic data. The diagram below groups them around their shared purpose, which is to make collected data usable and trustworthy for a model.
Quality control is broader than the other three because it explicitly includes removing sensitive information and removing toxic data. The source places these removals in the same family of work because they protect users and shape the model's later behavior.
How Tokenization Turns Text into Model Input
Tokenization is one of the four processes, and it is the one most tied to text. The source names it but does not describe the splitting rules, so this section offers only a general picture. Tokenization splits a piece of text into tokens, and each token is represented by a number the model can read. The example below is illustrative and was written for this article. The IDs are invented for teaching; real IDs depend on the tokenizer in use.
Read the map from left to right. The sentence the cat sat down becomes four tokens in order, and each token points to one numeric index. The model never receives the words themselves in this scheme; it receives the sequence of indices. Because tokenization is applied to unstructured text, it is one of the checks that has no equivalent in a plain table of fields.
Unstructured Data Versus Tabular Data
Two differences separate AI engineering data work from traditional machine learning data work. The first is the output the task allows, which you saw with close-ended and open-ended tasks. The second is 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.
| Aspect | Traditional machine learning | AI engineering with foundation models |
|---|---|---|
| Typical output | Close-ended: one value from a predefined set | Open-ended: a paragraph, summary, or code |
| Typical data form | Tabular data in rows and columns | Unstructured data such as text, images, or audio |
| Annotation difficulty | Usually a choice from a short list | Judging many dimensions at once |
| Preparation checks | Checks suited to defined fields | Different tools and checks suited to raw content |
How the two fields differ in output type and data format, based on the source's comparison
This is the reason data work becomes a much larger job in AI engineering. The same comparison also explains why the rest of the article's ideas, from annotation to manipulation, look different from the spam-classification examples that many introductions use.
Mistakes Beginners Make with Dataset Work
The ideas in this article are easy to state and easy to misapply. The four mistakes below come up often when people first think about preparing data.
Common mistake Assuming annotating open-ended examples is as easy as annotating close-ended ones
What it looks likeTreating a free-form support reply as either correct or incorrect, the way a spam label is either spam or not spam.
Why it failsA close-ended label chooses from a short fixed list. An open-ended answer must be judged on several dimensions at once, such as accuracy, completeness, tone, and appropriateness.
Do this insteadDefine the dimensions you are judging before annotating, and expect agreement between annotators to be harder to reach.
Common mistake Assuming the four manipulation processes must run in a fixed order
Why it failsThe source does not give an order for deduplication, tokenization, context retrieval, and quality control.
Do this insteadTreat the four as separate concerns that share one purpose, and do not assume a sequence the source does not state.
Common mistake Treating quality control as only removing duplicates
Why it failsQuality control explicitly includes removing sensitive information and removing toxic data. Deduplication is a separate process.
Do this insteadWhen planning quality control, include checks for sensitive and toxic content as well as for general data quality.
Common mistake Applying tabular-data checks to unstructured data unchanged
Why it failsUnstructured data such as raw text, images, or audio has no fixed grid of fields, so checks built around rows and columns may miss what matters.
Do this insteadChoose tools and checks suited to the actual form of the data.
Practical Notes for Planning a Dataset
Before collecting or generating anything, write down three things for each example set: where the data will come from, how it will be prepared, and how each example will get its label or target. The source frames dataset engineering around these three questions, and answering them early makes the later annotation and quality work easier to judge.
Practice: Sorting Tasks by Output Shape
For each task below, decide whether it is close-ended or open-ended. Then say which one would be harder to annotate reliably and why. Tasks: (1) labeling an email as spam or not spam; (2) choosing one of five predefined product categories for an item; (3) writing a summary of a meeting transcript; (4) producing a short piece of code that fixes a bug.
Hints
- Ask whether the output must come from a fixed list of predefined values.
- If the output could be a paragraph, a summary, or code, it is open-ended.
- Open-ended annotation requires judging several dimensions at once, such as accuracy, completeness, tone, and appropriateness.
Key Takeaways
- Dataset engineering covers curating existing data, generating new data when examples are scarce, and annotating data with labels, targets, or judgments.
- Close-ended tasks choose from predefined values, while open-ended foundation model tasks do not, which makes annotating open-ended queries much harder.
- AI engineering works mostly with unstructured data such as text, images, or audio, rather than the tabular rows and columns typical of traditional machine learning.
- The four central data manipulation processes are deduplication, tokenization, context retrieval, and quality control, which includes removing sensitive and toxic data; the source gives them no fixed order.