LearnThatStack Ace your next interview
Fine-Tuning & Model Customization · question
Question 3 of 56

What actually happens during supervised fine-tuning, mechanically?

beginner
← All Fine-Tuning & Model Customization questions
Re-explain

Supervised fine-tuning is the same next-token prediction as pretraining, run on your examples. The weights already exist, so each step only nudges them.

Each row is rendered with the chat template, then tokenized. The model does one forward pass and predicts a distribution over the next token at every position. Cross-entropy loss measures how surprised it was by your actual tokens. Backpropagation then works out how much each weight contributed to the loss. That gives a gradient, and the optimizer subtracts a small step.

for batch in loader:                  # one optimizer step per batch
    out = model(input_ids=batch["input_ids"], labels=batch["labels"])
    out.loss.backward()               # gradient for every trained weight
    optimizer.step()                  # weights move a little
    optimizer.zero_grad()

Nothing is inserted or looked up. The model becomes more likely to produce sequences that look like your answers. Fine-tuning learning rates are much smaller than pretraining ones, so each pass shifts behavior gently.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for Fine-Tuning & Model Customization One question at a time. Answer out loud, get graded, see what you missed.
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

What you can say

  1. Supervised fine-tuning is the same next-token prediction as pretraining, run on my examples, and since the weights already exist, each step only nudges them.
  2. Each row gets rendered with the chat template and tokenized, then one forward pass predicts a distribution over the next token at every position.
  3. Cross-entropy loss measures how surprised the model was by my actual tokens, and backprop works out how much each weight contributed to that loss.
  4. That gives a gradient, the optimizer subtracts a small step once per batch, and the gradients get zeroed before the next batch.
  5. Nothing is inserted or looked up. The model just gets more likely to produce sequences that look like my answers.
  6. Learning rates are much smaller than in pretraining, so behavior shifts gently. Push the rate too high and you start overwriting what the base model already did well.

Weak answers to avoid

  • Thinks fine-tuning inserts or stores knowledge Nothing is inserted or looked up. Say it is gradient descent on next-token loss that makes answer-like sequences more likely.
  • Says 'you retrain it on your data' and stops That restates the question. Walk one step in order: chat template, tokenize, forward pass, cross-entropy loss, backprop, optimizer step.
  • Treats SFT as a different objective from pretraining The loss is the same next-token cross-entropy. What changes is the data, the starting weights and a much smaller learning rate.
  • Says backprop updates the weights Backprop only computes gradients. The optimizer applies the update, scaled by the learning rate. Mixing them up suggests you haven't read a training loop.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the Fine-Tuning & Model Customization cheatsheet.

← Back to all Fine-Tuning & Model Customization questions
Pro · $10/mo

49 of 56 Fine-Tuning & Model Customization answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime