Training Data and Labels
The label is the signal. Without labels, the dataset would only contain emails, and there would be no signal telling the learning procedure which emails were right or wrong.
A Spam Filter That Must Judge Unseen Mail
Imagine an email service that must decide, for every incoming message, whether it is spam or not spam. The service has never seen the message that just arrived, so it cannot look up an answer in a table of known messages. What it needs is a system that has learned from earlier examples what spam tends to look like, and can then apply that learning to a message it has not encountered before.
What do you think happens?
Can the email service simply look up whether an arriving message is spam?
Reveal answer
No, because the message is new and has no known answer yet
The service has never seen this particular message, so it must apply what it learned from earlier examples to predict a label for it.
Learning From Labeled Examples
Supervised learning trains a model on a labeled dataset, pairing each example with its correct label.
In the spam case, the training dataset is a collection of emails. Each email comes with a label of either 'spam' or 'not spam' that a human has identified. The examples are the inputs the model will look at, and the labels are the answers it is supposed to learn to produce.
The label is the signal. Without labels, the dataset would only contain emails, and there would be no signal telling the learning procedure which emails were right or wrong.
The two example emails above are invented for illustration, but the structure matches the source: each email text is the input, and each label is the correct answer stored alongside it. During training, the learning algorithm sees both halves of every pair. Later, during inference, the message the service is judging arrives without its label, so the label is the thing the model must produce.
The Three Parts of the Workflow
The supervised learning workflow for predictive modeling is a sequence of stages that run in a fixed order. Stage one is training, in which a learning algorithm uses the labeled dataset to produce a trained model. Stage two is inference, in which the trained model is applied to new observations whose labels are unknown. Between these two stages sits a model evaluation step, which checks that the trained model meets the performance criteria we care about before it is allowed to make predictions in a real application.
Read the diagram from left to right. The labeled dataset and the learning algorithm together make up the training stage, and their result is a trained model. The model is then evaluated. Only after that does the workflow move to inference, where the trained model receives new observations and returns predicted labels. The trained model is the hinge of the whole process: it is the thing training produces and the thing inference uses.
Why Evaluation Sits Between Training and Inference
A trained model is not automatically ready for use. Training produces a model that has fit the labeled examples, but the workflow requires an additional check before the model is applied to real observations. The source states that model evaluation should be added between the training and inference stages to ensure that the model satisfies the performance criteria before it is used in a real-world application.
Tracing a Spam Classifier Through Each Stage
The clearest way to see the workflow is to follow one concrete task from start to finish. Here the task is spam classification, and we track what data enters each stage and what comes out.
Following One Message Through the Workflow
The email service has a labeled set of past emails and has trained a spam model. A new message arrives with no label. What goes in and what comes out at each stage?
- 1Training input
The labeled emails go in: each email text paired with either 'spam' or 'not spam'. The learning algorithm uses this complete pairing.
- 2Training output
A trained model comes out. It has fit the labeled examples, but it is not yet allowed to label real mail.
- 3Evaluation
The trained model is checked against the performance criteria. If it does not meet them, it should not move on to inference.
- 4Inference input
The arriving message goes in with its label unknown. The model receives only the observation, not the answer.
- 5Inference output
A predicted label comes out, either 'spam' or 'not spam'. This is the model's answer for the new message.
Labels are known during training and produced by the model during inference. Evaluation sits between them so that only a model meeting the criteria makes predictions.
What do you think happens?
Which stage of the spam workflow receives a label as part of its input?
Reveal answer
Training
During training both the examples and their labels are known. During inference only the new observation is given, and its label is unknown.
Known Versus Predicted Across the Two Stages
The two stages use data in opposite ways. During training, both the examples and their labels are known, and the learning algorithm uses that complete pairing to build the model. During inference, the model receives only the new observations. Their labels are unknown, and the model's job is to predict them.
| Aspect | Training stage | Inference stage |
|---|---|---|
| Data supplied | Labeled dataset of examples and their correct labels | New observations whose labels are unknown |
| Role of the labels | Known, and used to learn | Unknown, and the target of prediction |
| What the stage produces | A trained model | Predicted labels |
| Position in the workflow | First stage | Second stage, after evaluation |
Which parts of each stage are known in advance and which are produced by the model
The Same Workflow for LLMs
The same workflow describes how Large Language Models are trained and used. The general pattern of training, evaluation, and inference stays the same. What changes is the behavior of the inference stage, which differs between the two kinds of LLM task the source distinguishes: text classification and text generation.
| Aspect | Text classification | Text generation |
|---|---|---|
| Training data | Texts paired with a class label, such as spam or not spam | Text examples used to learn how to produce text |
| Labels | Chosen from a fixed set of categories | The continuation or target text that the model learns to produce |
| Inference output | A predicted category for the input text | Newly produced text in response to the input |
| Workflow stages | Training, evaluation, inference | Training, evaluation, inference |
The stages stay fixed while the training data, labels, and outputs change
An LLM used as a spam filter behaves like the spam classifier above: its inference output is a label. An LLM used to draft a reply to a message has the same three stages, but its inference output is a block of new text rather than a category. The training and evaluation stages still come before inference in both cases.
Mistakes Beginners Make With Labels and Stages
Common mistake Assuming the model can see labels during inference
What it looks likeExpecting the spam model to be given 'spam' or 'not spam' for an arriving email before it judges it.
Why it failsDuring inference the labels are unknown. The model receives only the new observation and is asked to predict its label.
Do this insteadTreat the labels as known only during training, and as the prediction target during inference.
Common mistake Skipping evaluation because training finished
What it looks likeDeploying a trained spam model straight to live mail as soon as training ends.
Why it failsA trained model has fit the labeled examples, but the workflow requires a check that it meets the performance criteria before real use.
Do this insteadPlace the evaluation step between training and inference, and move on only when the criteria are satisfied.
Common mistake Training on unlabeled emails
What it looks likeCollecting thousands of emails with no spam or not spam tags and expecting supervised learning to proceed.
Why it failsWithout labels the dataset has no signal telling the procedure which answers were right or wrong.
Do this insteadPair each training example with its correct label before training.
Common mistake Confusing the stage order, and thinking inference happens before the model exists
Practice Tracing a New Task
A company wants to classify customer support tickets as urgent or not urgent. Describe the training data, the labels, what the evaluation step checks, and what the inference input and output would be.
Hints
- Start by asking what a labeled training example looks like for this task: a ticket paired with urgent or not urgent.
- Remember that evaluation sits between training and inference and checks the performance criteria.
- At inference, the ticket arrives with its label unknown, and the model returns a predicted label.
Summary of the Workflow
- 1Supervised learning trains a model on a labeled dataset, pairing each example with its correct label.
- 2Training uses a learning algorithm to turn labeled examples into a trained model, and inference applies that model to new observations whose labels are unknown.
- 3Model evaluation sits between training and inference to check that the model meets the performance criteria before it makes predictions in a real application.
- 4The same workflow applies to LLMs for text classification and text generation, with the inference output differing between the two tasks.
At a glance
- Supervised learning trains a model on a labeled dataset, pairing each example with its correct label.
- The workflow has two main stages: training produces a trained model from labeled examples, and inference applies that model to new observations with unknown labels.
- Model evaluation between training and inference checks the performance criteria before the model is used in a real application.
- The same workflow describes LLM training and use for text classification and text generation, with inference outputs differing between the two.