esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

What Is SFT / Instruction Tuning?

What supervised fine-tuning is, how one training row teaches a model, how it relates to instruction tuning, and where it stops, explained for your AI interview.

In short

SFT (supervised fine-tuning) trains a pretrained model on example inputs paired with the answers we want. Instruction tuning is SFT where those examples are instructions across many tasks.

11 min readIntermediateVery common · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

SFT stands for supervised fine-tuning. We take a model that already reads language well and train it on examples: an input, and the answer we want. Each example teaches it to copy that behaviour, because a loss scores how far its words are from the target. Instruction tuning is the same method, with the examples written as instructions across many tasks. SFT shapes behaviour and format. Facts that change belong in documents the model searches when it answers.

What is SFT, in plain words?

SFT means supervised fine-tuning. You take a model that has already learned language from a huge pile of text, then train it a little more on your own examples: an input on one side and the reply you want on the other. Training changes the weights, the numbers inside the model that decide its answers.

Think of a new support agent who reads a stack of past tickets, each with the senior agent's reply beside it. After enough of them, the new agent writes replies in the house style without being told each rule. A tuned model learns the same way, from examples rather than a rulebook.

Picture a freight broker's support desk, a made-up case with realistic numbers. The team has 1,500 approved replies to delay questions, and wants each reply to open with the new date and state the fee rule the same way every time. SFT is how the model learns that pattern.

Key words

SFT
Supervised fine-tuning: more training on example inputs and the answers we want.
Training row
One example, usually a request followed by the reply we want.
Loss
A score for how far the model's guess is from the target words. Training tries to lower it.
Instruction tuning
SFT where the examples are instructions for many different tasks.
Evals
A fixed test set of questions with good answers, plus a score, so you can check how a model does.

How does one training row teach the model?

A training row holds a list of messages: the user's request first, then the reply we want last. OpenAI's guide asks for the chat format, with one complete JSON structure on each line of the file, so one row is one line.

How one training row moves the model

User's message

a real request from the support desk

Model

guesses each next word from earlier ones

Scoring

Target reply

the expert reply we want

Gap to target

scores the guess, word by word

Weights nudged

a smaller gap next time

  1. 1The request goes into the model.
  2. 2The model's guess goes to the scoring step.
  3. 3The expert's reply is the target, and the two are compared word by word.
  4. 4The gap becomes a small nudge to the weights, so the next guess is closer.
A request goes into the model, and its guess is set against the expert's reply. The gap between them nudges the weights a little, so the next guess is closer. Training repeats this over many batches of rows.

The loss has a standard form. Hugging Face's TRL library describes it as the token-level cross-entropy loss. In words, it measures how much probability the model gave to the right next word, and training pushes that probability up.

Not every word has to count. TRL can train on the assistant's messages only, through a setting called assistant_only_loss, and padding, the filler that makes rows the same length, is ignored in the score. Which setting is right depends on your data and your goal, so check it before a run.

Here is the idea in plain Python. It prints which words a loss would count. The prompt words get -100, the value that tells the loss to skip them.

Python
import json

IGNORE = -100  # the loss skips these positions

rows = [
    {"messages": [
        {"role": "user", "content": "Shipment 4471 is two days late. What do I tell the customer?"},
        {"role": "assistant", "content": "Apologise, give the new date, offer a 5% late-fee refund."},
    ]},
    {"messages": [
        {"role": "user", "content": "Why was the truck held at the port?"},
        {"role": "assistant", "content": "Explain the customs hold and give the release time."},
    ]},
]

for row in rows:
    if row["messages"][-1]["role"] != "assistant":
        raise ValueError("each row must end with the reply we want")
    print(json.dumps(row))

def loss_mask(row):
    # Like TRL's opt-in assistant_only_loss: only the assistant's words count.
    return [(word, m["role"] == "assistant")
            for m in row["messages"] for word in m["content"].split()]

for word, counted in loss_mask(rows[0])[:3] + loss_mask(rows[0])[-3:]:
    print(f"{word:<12} {'loss' if counted else IGNORE}")

Output

{"messages": [{"role": "user", "content": "Shipment 4471 is two days late. What do I tell the customer?"}, {"role": "assistant", "content": "Apologise, give the new date, offer a 5% late-fee refund."}]}
{"messages": [{"role": "user", "content": "Why was the truck held at the port?"}, {"role": "assistant", "content": "Explain the customs hold and give the release time."}]}
Shipment     -100
4471         -100
is           -100
5%           loss
late-fee     loss
refund.      loss

How is instruction tuning different from SFT?

  • SFT

    The method

    Training on pairs of input and the output we want. The pairs can be about anything.

  • Instruction tuning

    A kind of SFT

    The pairs are instructions for many tasks, such as summarise this or classify that.

  • Why it matters

    Follows new requests

    The FLAN paper found instruction tuning helps models handle tasks they were not tuned on.

  • “Supervised Fine-Tuning (SFT) is the simplest and most commonly used method to adapt a language model to a target dataset.”

    Hugging Face TRL docs

  • “finetuning language models on a collection of tasks described via instructions”

    FLAN paper (Wei et al.)

  • “then memorizes the dataset instead of learning generalizable knowledge”

    OpenAI's SFT guide

So instruction tuning is a particular use of SFT. InstructGPT shows one order for building a chat model: first SFT on demonstrations written by labellers of the desired behaviour, then a second stage that learns from people ranking the model's outputs.

  1. 1

    Pretrain on text

    Learn language from a huge pile of text. This step is not SFT.

  2. 2

    SFT on demonstrations

    Train on example requests with good answers, so the model follows instructions.

  3. 3

    Learn from rankings

    People rank outputs, and reinforcement learning from those rankings trains the model further (called RLHF).

Where does SFT stop working?

SFT copies its examples, so the examples decide the behaviour. Three limits come up in almost every real project.

  • Bad examples teach bad habits

    Inconsistent replies in the data make an inconsistent model.

  • Frozen facts

    Tuned weights keep what they learned until you train again. A changed fee won't show up on its own.

  • Memorising

    Too many passes over the same small set make the model memorise it, so it stops handling new cases well.

Where a changed fact ends up

Fact in the weights

Last year's fee

copied into the weights

Fact in a searched document

Current fee sheet

read when the question is asked

Old fee quoted

the customer is overcharged

Current fee quoted

matches the latest sheet

  1. 1The tuned model answers from what it learned in training, so it gives last year's fee.
  2. 2The model reads the current sheet when asked, so it quotes the new fee.
A fact baked into the weights stays frozen at training time, so the model can quote an old fee. A fact in a document the model searches at answer time stays current.

Take the freight team. Suppose it tunes on last year's fee of 5%, and in May the fee drops to 3%. The tuned model keeps saying 5% until someone retrains it. The fix is to fetch the current fee sheet when the question is asked, so the model reads the new number.

Tip

Asked what to do first? Say evals. OpenAI's guide says to set up evals before you invest in fine-tuning, so you can tell whether tuning helped at all.

How would you start tuning for a freight support desk?

  1. 1

    Write the test first

    Collect 200 real delay questions with a good answer each. Score the current model on them so you have a baseline.

  2. 2

    Clean the training replies

    Keep only replies the senior agents approved, in one format, with the fee rule written the same way every time.

  3. 3

    Run one small tuning job

    Train on the 1,500 approved rows, then check the test score. Stop if it stops improving.

  4. 4

    Compare with the base model

    Run the same 200 questions on the base model and the tuned one, and read the answers as well as the score.

  5. 5

    Keep facts outside the weights

    Put the fee sheet in a document the model searches. A May change then needs no retraining.

What does the interviewer want to hear?

A strong answer covers

  • A plain definition: SFT trains on example inputs and the answers we want.
  • The loss: a score for how far the guess is from the target words.
  • Instruction tuning as SFT on instructions across many tasks.
  • Where it stops: copied bad examples, frozen facts, memorising too many passes.
  • Evals first, then tune for format and behaviour. Keep changing facts in documents.
  • A plan that names the data, the test set and the fallback.

Common traps

  • Trap"SFT teaches the model the latest facts."

    BetterIt teaches behaviour and format well. Facts that change belong in documents the model searches.

  • Trap"More passes over the data always make it better."

    BetterPast a point the model memorises the examples. Watch a test set you kept out of training.

  • Trap"Instruction tuning is a different method from SFT."

    BetterIt is SFT where the examples are instructions across many tasks.

Can you spot the weak training row?

Spot the weak row

A dispatch team tunes a model on these replies. Which row would most likely hurt the tuned model?

Quick check

Dispatchers need a chat model that always replies in one short format. What is the best first step?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q281Fine-tune vs RAG vs prompting: when to use which?10 min
  2. Q284What is LoRA?10 min
  3. Q288What is RLHF?10 min
  4. Q294How do you prepare a fine-tuning dataset?11 min
  5. Q297How do you spot overfitting during fine-tuning?11 min
  6. Q016Pretraining vs fine-tuning vs instruction tuning?10 min

Learn it in depth

Last updated on 26 November 2026

Thinking about tuning a model on your team's replies?

I design and build AI agents, including the test sets, evals and guardrails they need before any training run. Book a short call and tell me what the model gets wrong today.