Concepts / Training Data and Labels

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.

  • Programming

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?

  • Yes, by searching a list of every message ever sent

  • No, because the message is new and has no known answer yet

Reveal answer
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

Definition

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.

Key point

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.

Claim your free prizetodaylabel: spamMeeting moved to 3 pmlabel: not spamsame dataset, different labels
How does each training example, an email's text, connect to its correct label, and what does the model receive versus what is hidden from it?

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.

Labeled datasetexamples with labelsLearning algorithmTrained modelModel evaluationperformance criteria met?Inferencenew observationsPredicted labelslabels unknown beforehandfeedsproducesis checkedonly if criteria are metreturns
What happens to the trained model after training, and why must it be checked before it is used on new inputs during inference?

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.

Labeled emailsemail plus spam or not spamTraininglearning algorithmTrained spam modelEvaluationperformance criteria metArriving emaillabel unknownPredicted labelspam or not spaminputoutputoutput checkedmodel applied toinput
What data goes into training, evaluation, and inference for a spam classifier, and what comes out of each stage?
Worked example

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?

  1. 1
    Training input

    The labeled emails go in: each email text paired with either 'spam' or 'not spam'. The learning algorithm uses this complete pairing.

  2. 2
    Training output

    A trained model comes out. It has fit the labeled examples, but it is not yet allowed to label real mail.

  3. 3
    Evaluation

    The trained model is checked against the performance criteria. If it does not meet them, it should not move on to inference.

  4. 4
    Inference input

    The arriving message goes in with its label unknown. The model receives only the observation, not the answer.

  5. 5
    Inference output

    A predicted label comes out, either 'spam' or 'not spam'. This is the model's answer for the new message.

Result

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?

  • Training

  • Inference

  • Both training and inference

Reveal answer
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.

AspectTraining stageInference stage
Data suppliedLabeled dataset of examples and their correct labelsNew observations whose labels are unknown
Role of the labelsKnown, and used to learnUnknown, and the target of prediction
What the stage producesA trained modelPredicted labels
Position in the workflowFirst stageSecond 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.

AspectText classificationText generation
Training dataTexts paired with a class label, such as spam or not spamText examples used to learn how to produce text
LabelsChosen from a fixed set of categoriesThe continuation or target text that the model learns to produce
Inference outputA predicted category for the input textNewly produced text in response to the input
Workflow stagesTraining, evaluation, inferenceTraining, evaluation, inference

The stages stay fixed while the training data, labels, and outputs change

In the real world

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 like

    Expecting the spam model to be given 'spam' or 'not spam' for an arriving email before it judges it.

    Why it fails

    During inference the labels are unknown. The model receives only the new observation and is asked to predict its label.

    Do this instead

    Treat the labels as known only during training, and as the prediction target during inference.

  • Common mistake

    Skipping evaluation because training finished

    What it looks like

    Deploying a trained spam model straight to live mail as soon as training ends.

    Why it fails

    A trained model has fit the labeled examples, but the workflow requires a check that it meets the performance criteria before real use.

    Do this instead

    Place 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 like

    Collecting thousands of emails with no spam or not spam tags and expecting supervised learning to proceed.

    Why it fails

    Without labels the dataset has no signal telling the procedure which answers were right or wrong.

    Do this instead

    Pair 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

MEDIUM

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

  1. 1
    Supervised learning trains a model on a labeled dataset, pairing each example with its correct label.
  2. 2
    Training uses a learning algorithm to turn labeled examples into a trained model, and inference applies that model to new observations whose labels are unknown.
  3. 3
    Model evaluation sits between training and inference to check that the model meets the performance criteria before it makes predictions in a real application.
  4. 4
    The 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.

Related concepts

More concepts starting with T