Back to LLMs
Next: RLHF

Fine-tuning

Teaching New Tricks

Difficulty
Intermediate
Duration
12-15 min
Prerequisites
Pre-training
Step
1/ 7

Why Pre-training Isn't Enough

A pre-trained LLM like GPT or LLaMA has learned language from trillions of tokens scraped from the internet. It can predict the next token brilliantly. But it has a fundamental problem: it doesn't know what you want it to do.

Ask a pre-trained model "What is the capital of France?" and it might continue with:

  • "What is the capital of Germany? What is the capital of..." (it sees a pattern of questions)
  • "...a question often asked by geography students" (it describes the question)
  • "Paris" (what you actually wanted — but only sometimes)

The model is a text completion engine, not an assistant. It hasn't learned to:

  • Follow instructions ("Summarize this article in 3 bullet points")
  • Stay on topic (instead of generating tangentially related text)
  • Refuse harmful requests ("How to build a bomb" → should decline)
  • Match a specific tone, format, or domain

Fine-tuning bridges this gap: you take the pre-trained model and continue training it on a curated dataset that teaches the specific behavior you want. The model keeps its broad language knowledge but learns new skills on top.

Pre-trained vs Fine-tuned Model

CapabilityPre-trained ModelFine-tuned Model
Language understandingExcellentExcellent (retained)
Following instructionsPoor — just completes textGood — trained on instruction-response pairs
Specific domain knowledgeGeneral onlyDeep (if fine-tuned on domain data)
Output format controlUnpredictableConsistent (JSON, markdown, etc.)
Safety / alignmentNone — will generate anythingTrained to refuse harmful requests
Tone / personalityMimics training data mixMatches desired persona

Pre-training vs Fine-tuning Analogies

AnalogyPre-trainingFine-tuning
EducationGeneral education (K-12)Medical school specialization
CookingLearning all cuisinesMastering French pastry
MusicLearning to play instrumentsRehearsing for a specific concert
LanguageLearning vocabulary and grammarLearning legal or medical writing