Fine-Tuning
Beginner 11 min read Fine-Tuning

Fine-Tuning Overview

Teaching with examples, not words

Fine-tuning updates part of a pre-trained model's weights on your data — teaching style, formats, and behaviors no prompt reliably conveys. It's a quality lever with real cost and data requirements.

fine-tuningweightsadaptationbehaviordatasetfull tuning
Prerequisites: Model Serving
Before we start

What you will learn

  • Explain what fine-tuning changes
  • Recognize when tuning is warranted
  • Distinguish tuning from prompting
Introduction

What is this?

Fine-tuning further trains a pre-trained model on a curated dataset so its weights reflect your domain: output format, tone, tool-call shapes, classification behavior. Unlike prompts, these behaviors persist in weights — consistent but requiring datasets, compute/budget, and eval discipline.

Motivation

Why do you need it?

  • Prompt-only quality plateaus; tuning moves the floor up.
  • Format-compliance improves beyond what prompts anchor.
  • Smaller tuned models can match bigger prompted ones at lower cost.
  • Behavior becomes encoded, not renegotiated each call.
Think about it

Mental model

Imagine

Teaching a new hire by example after onboarding docs

Think of

Fine-tuning

The handbook (prompt) sets rules everyone reads; but Junior still formats tickets wrong. A training block (fine-tuning) with real examples makes the behavior automatic — they stop reading the handbook and just do it right. The handbook stays, but the training embeds the skill.

Mechanics

How it works

  • Collect representative examples of desired behavior.
  • Prepare a dataset (input → ideal output).
  • Choose tuning type: full, LoRA, or provider API.
  • Train against the base model; evaluate on held-out.
  • Compare vs prompt-only baseline; A/B rollout.

Tuning journey.

Collect
Prepare
Tune
Eval
Ship
Real world

In production

  • Support tones + formats become consistent across the fleet.
  • Tool-selection models tune on your schema set.
  • Classification graders tune for your domain rubric.
Guidelines

Best practices

  • Prompt first, tune only when prompted quality plateaus.
  • Hold out eval data never seen in training.
  • Compare every tuning against the prompt-only baseline.
  • Track drift after tuning: it can regress other skills.
Watch out

Common mistakes

  • Tuning on data that's already easy for prompts.
  • No held-out eval (the model parrots its own examples).
  • Ignoring capability regressions in other domains.
Root cause analysis

Common issues

Error
Tuned model overfits training
Root cause

Small dataset or high capacity

Fix

More diverse samples; regularization; eval on held-out.

Error
No improvement over baseline
Root cause

The lesson was already learnable via prompt

Fix

Re-scope the target; use few-shot check first.

When things break

Debugging tips

  • Tuned behavior missing → dataset imbalance or your eval leaks.
  • Sudden regressions → eval for unrelated skills.
  • Format complaints → include format-broken negatives in data.
Interviews

Interview checkpoint

Practice

Hands-on lab

Size a Fine-Tuning Dataset
25 min · beginner
In progress
Objectives
  • Split rows into train and validation sets
  • Estimate tokens per example
  • Compare an epoch's token cost against the budget

Size a Fine-Tuning Dataset

25 min · beginner

0/3 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

Fine-tuning changes a model's…

2

Tuning should always beat a prompt baseline.

Go deeper

Official documentation