Skip to content

What is the difference between pre-training, fine-tuning, and in-context learning?

Beginner · 2 min read · Fine-Tuning & Adaptation

Open in study mode to save this question and track progress

Short answer: Pre-training builds foundational language understanding by updating all model weights on trillions of tokens via unsupervised next-token prediction; fine-tuning updates model weights on task-specific dataset pairs to adapt behavior; in-context learning (RAG & prompting) adapts model output at inference time using context window instructions without modifying any model weights.

Detail

Model adaptation strategies trade off compute cost, dataset requirements, and update latency:

DimensionPre-TrainingFine-Tuning (Full / PEFT)In-Context Learning (Prompt/RAG)
Weight ModificationUpdates 100% of parametersUpdates 100% (Full) or <1% (LoRA)0% (Weights frozen)
Compute / GPU CostMillions of USD (Thousands of H100 GPUs)Hundreds of USD (Single/Few GPUs)API invocation token cost
Data RequirementTrillions of tokensHundreds to thousands of curated pairs1 to 20 context documents
Knowledge UpdatePermanent baseline knowledgeAdaptation of tone, format, domain styleReal-time / Dynamic facts
Latency ImpactN/ANone (Same architecture inference)Higher latency due to prompt token overhead

Example

Conceptual Python distinction:

python
# 1. In-Context Learning: Prompt contains instruction + data (No weight changes)
icl_prompt = "Translate to French:\nEnglish: Hello\nFrench:"

# 2. Fine-Tuning (LoRA / HuggingFace Trainer): Updates adapter weight matrix
# trainer.train() updates model parameters based on task loss loss.backward()

Interview tips

  • Emphasize the core rule of thumb: Use RAG/In-Context Learning to provide knowledge and dynamic facts; use Fine-Tuning to teach format, style, tone, and domain syntax.
  • Mention PEFT/LoRA as the modern standard for cost-effective fine-tuning.

⬅ Back to Fine-Tuning and Adaptation · All topics