Concepts / Classification Fine-Tuning for Large Language Models

Classification Fine-Tuning for Large Language Models

The text is the material and the instruction is the direction. The model's output depends on both, so changing only the instruction changes the response even when the material stays the same.

  • Programming

Same Text, Different Requests

Imagine sending the same short message to a language model twice. In one case you ask whether the message looks like spam. In the other you ask it to render the message in another language. The text is identical in both cases, yet the useful response depends entirely on the written request attached to it. That gap between the text and the request is the central idea behind instruction fine-tuning.

This article follows that idea step by step. You will first see what a training set looks like when every example carries an instruction. Then you will trace one example through the model, compare the technique with the other common method the source names, and check your understanding with a prediction and a practice problem.

Following the Spam and Translation Paths

The source illustrates the technique with two scenarios side by side. In the first, the model must decide whether a given text is spam. In the second, the model receives an English sentence along with an instruction to translate it into German. Laid out as flows, both scenarios have the same shape: material plus instruction enters the model, and an output comes out.

Message textmaterial to considerLanguage modelreads both pieces togetherYes or no answersingle answerEnglish sentencematerial to act onLanguage modelreads both pieces togetherGerman renderingthe model outputInstruction: answeryes or nosays how to format theanswerInstruction:translate to Germannames the target languagematerialinstructionoutputmaterialinstructionoutput
Which pieces enter the model, and what comes out, in the spam path and the translation path?

Read the spam path from top to bottom. The message is the material under consideration, and the instruction tells the model how to format its answer: respond with yes or no. The language model takes both pieces together and produces a single answer. The translation path has the same shape. The English sentence is the material, the instruction names the target language, and the model's output is the German rendering. The structure is identical even though the tasks differ, which is exactly why one training approach can cover both.

Key point

The text is the material and the instruction is the direction. The model's output depends on both, so changing only the instruction changes the response even when the material stays the same.

Anatomy of One Training Example

A training set for instruction fine-tuning is a collection of many tasks, and each task is presented alongside its own specific instruction. The source puts it this way: the model is trained on a set of tasks, with each task presented together with a specific instruction. The goal is to improve the model's ability to understand and execute tasks described in natural language prompts.

Instructionsays what should be doneInput (optional)the material to act onExpected outputthe response the modelshould learn to givedirectsleads to
What does each field of a single training example contribute, and how do the fields relate when the example is used for training?

The three fields work together. The instruction states the task, the input supplies the material the task applies to, and the expected output is the response that goes with that pair. The input is marked optional because some tasks can be stated fully by the instruction alone. The source's translation scenario fits this pattern: the English sentence is the material, and the instruction names the target language.

python
Notes on the code
  • Each dictionary is one training example, holding one task.
  • The instruction says what to do; the input is the material; the output is what the model should produce.
  • The two examples share the same structure even though the tasks differ.

Tracing One Example Through the Model

Follow the spam scenario one stage at a time. The model is not handed the message and then asked a question later. The instruction and the material arrive together, and the model's output is shaped by both.

Worked example

Spam decision with an attached instruction

A message reads: 'Your account statement is ready. Log in through the official app to view it.' The instruction says: decide whether the message is spam, and answer yes or no. What travels into the model, and what comes out?

  1. 1
    Identify the material

    The message text is the material under consideration. It is the thing the task acts on.

  2. 2
    Identify the instruction

    The instruction tells the model the task (spam or not) and the response format (yes or no).

  3. 3
    Combine the pieces

    Material and instruction enter the language model together. The instruction is part of the input the model reads, not a separate step applied afterwards.

  4. 4
    Produce the output

    The model returns a single answer in the format the instruction asked for, here a yes or no response about spam.

Result

The message and the instruction go in together, and a yes or no answer comes out. The instruction determines the form of the response.

What do you think happens?

Keep the same English sentence as the material, but replace the spam instruction with 'Translate this into German.' What changes in what comes out of the model?

  • Nothing changes, because the material is the same

  • The output becomes a German rendering of the sentence instead of a yes or no answer

  • The output becomes a list of spam words found in the sentence

Reveal answer
Answer:

The output becomes a German rendering of the sentence instead of a yes or no answer.

The material stayed the same, but the instruction changed. The source's two scenarios show that the written request determines the useful response, so the output follows the new instruction.

Instruction Fine-Tuning and Classification Fine-Tuning

The source names instruction fine-tuning and classification fine-tuning as the two most common ways to fine-tune language models. This article concentrates on the first. The source does not describe classification fine-tuning in detail, so the comparison below records only what the source states, and treats the second method as a distinct approach you will meet alongside this one.

Tasks with writteninstructionsMaterial plusinstructionResponse that followsthe instructionNamed as a commonmethodDescribed in detailNot in sourceeach example pairsmodel producessource does notleft for later study
How do the two methods differ in what the model reads, what it outputs, and what the training data looks like?

Misreadings to Avoid

  • Common mistake

    Treating the instruction as just a label for the answer

    What it looks like

    Reading 'Is the following message spam? Answer yes or no' as if it were only the category name attached to the message.

    Why it fails

    The source describes the instruction as saying what should be done with the material that follows it. It shapes the task and the response format, not only the category.

    Do this instead

    Think of the instruction as the direction for the task. The training example holds the direction, the material, and the expected output together.

  • Common mistake

    Thinking the instruction is added only at inference time

    What it looks like

    Assuming the model is trained on bare messages and only later given the instruction when someone uses it.

    Why it fails

    The source states that each task is presented alongside a specific instruction during training, and that the model learns that a written direction describes what to do with the material.

    Do this instead

    Treat the instruction as part of the training examples. The model learns from pairs of instruction and material, so the instruction is present during training as well as when the model is used.

  • Common mistake

    Assuming the text alone determines the answer

    Why it fails

    The spam and translation scenarios use identical material with different instructions to produce different useful responses.

    Do this instead

    When predicting a model's output, check the instruction first, then the material.

Applying the Pattern to a New Message

EASY

A training example has the message 'Your package has shipped and arrives Tuesday.' Write two different instructions that could be paired with this same message: one that asks for a spam decision and one that asks for a German translation. For each, name the material, the instruction, and the output you would expect the model to learn to produce.

Hints
  • The material is the same in both examples; only the instruction should change.
  • Use the spam and translation scenarios from earlier as the pattern to copy.
  • For the spam instruction, a yes or no response is the expected output; for the translation instruction, the expected output is a German sentence.

Key Takeaways

  • A training set for instruction fine-tuning holds many tasks, and each task is presented alongside its own specific instruction.
  • Each example pairs material to act on with a written instruction, and the model learns that the instruction describes what to do with that material.
  • In the spam and German translation scenarios, material and instruction enter the model together and an output comes out; changing the instruction changes the useful response.
  • Instruction fine-tuning and classification fine-tuning are two distinct common methods named in the source; this article concentrates on the first.
  • Misreadings to avoid include treating the instruction as only a label and treating it as something added only at inference time.

Related concepts

More concepts starting with C