Fine-Tuning LLMs Tutorial 120 lessons · 3:01:51+ of video
Fine-Tuning LLMs Home What Fine-Tuning Is
What Is Fine-Tuning? How LLMs Work Pretraining vs Fine-Tuning When to Fine-Tune
Prompting, RAG or Fine-Tuning? What Fine-Tuning Can and Can't Do The Tools: Transformers, PEFT, TRL Setup, the Hub and pipeline()
Setting Up The Hugging Face Hub Your First Model: pipeline() Tokenizers
Tokenizers Token IDs and Special Tokens Padding, Truncation, Attention Masks Models, Logits and Generation
Loading a Model Logits and Probabilities Generating Text Decoding, Instruct Models and Chat Templates
Decoding Settings Base vs Instruct Models Chat Templates Memory and Data Types
Parameters and Memory Data Types Training Memory How Training Works
Loss Gradients and Learning Rate Epochs, Batches, Steps Working with Datasets
The datasets Library map, filter, split Our Project Data Classification Fine-Tuning
Classification Fine-Tuning Tokenize the Dataset A Classification Model Training with the Trainer
Trainer and TrainingArguments Train It Evaluate It Overfitting, Saving and Using
Overfitting Save and Load Use Your Model Fine-Tuning a Language Model
Full Fine-Tuning an LLM Labels for Causal LMs Why We Need PEFT LoRA Explained
PEFT: the Big Idea LoRA Explained Rank and Alpha LoRA with PEFT
Which Layers? LoraConfig get_peft_model Instruction Data
Instruction Data Formats Build a Chat Dataset Train on Answers Only Your First LoRA Fine-Tune
TRL and SFTTrainer SFTConfig First LoRA Run Results, Loss and Hyperparameters
Before and After Reading the Loss Hyperparameters That Matter Save, Load and Merge Adapters
Saving Adapters Loading Adapters Merging Adapters Quantization and QLoRA
Quantization 4-bit NF4 QLoRA Fitting Training into Memory
GPU Memory Budget Gradient Accumulation Gradient Checkpointing Precision, Length and Hardware
Mixed Precision Sequence Length and Packing Where to Train Bigger Models and Many Adapters
A Bigger Model Many Adapters Practice Data: Quality and Collection
Quality Beats Quantity Collecting Data Synthetic Data Data: Cleaning, Splits and Size
Cleaning and Dedup Splits and Leakage How Much Data? Data: Prompts, Conversations and Sharing
System Prompts Multi-turn Data Sharing Datasets Data: Balance, Safety and Practice
Label Balance Bias and Safety Data Practice Evaluating a Fine-Tuned Model
Why Evaluation Is Hard Exact Match and Valid JSON Perplexity Evaluation Loops, Judges and Forgetting
An Evaluation Loop LLM as a Judge Catastrophic Forgetting Comparing Runs and Error Analysis
Comparing Runs Error Analysis Evaluation Practice Preference Tuning and DPO
Preference Tuning DPO DPO with TRL Beyond LoRA: PEFT, Distillation and Prompting
Other PEFT Methods Distillation When Not to Fine-Tune Sharing and Serving Your Model
Push to the Hub Serving with vLLM GGUF and Ollama Fast Inference, Many Adapters and Costs
Fast Inference Serving Many Adapters Costs Project: Plan, Data and Baseline
Project: Plan Project: Baseline Project: Dataset Project: Train, Evaluate and Improve
Project: Train Project: Evaluate Project: Improve Project: Save, Use and Wrap-up
Project: Merge and Save Project: Chat With It Project: Wrap-up Mistakes, Troubleshooting and Interview Basics
Common Mistakes Troubleshooting Interview: Core Interview Questions and Cheat Sheets
Interview: LoRA and Training Cheat Sheet: Code Cheat Sheet: Settings Final Quiz, Next Steps and Recap
Final Quiz What to Learn Next Course Recap Fine-Tuning LLMs · Lesson 3 of 120
Pretraining vs Fine-Tuning Two stages of training.
⏱ 2 min read ▶ Video at 3:45 🎓 Free
▶ starts at 3:45 Every model you'll fine-tune was trained in two stages. Understanding these two stages explains why fine-tuning is so cheap, and so useful.
Two stages of training Why fine-tuning is cheap And why it's useful Stage one is called pretraining. The model reads trillions of words, from books, websites, and code, and learns to predict the next token. That takes weeks, on thousands of GPUs. The result is a base model. It knows a little about everything. Stage two is fine-tuning. We train the base model on a small set of our own examples. That takes hours, often on one GPU. The result is a specialist.
Let's compare them. Pretraining uses trillions of words. Fine-tuning uses hundreds, or thousands, of examples. Pretraining costs millions of dollars, and only big labs do it. Fine-tuning can cost a few dollars, and anyone can do it. In this course, we only do fine-tuning. Someone else has already done the expensive part.
Pretraining Trillions of words Weeks, thousands of GPUs Millions of dollars, big labs Fine-tuning Hundreds of examples Minutes to hours A few dollars, anyone Prefer to watch? The full Fine-Tuning LLMs course is free All lessons in one video with animations, real code and chapters.
Watch free Throughout this course, we'll help one small business. Riverside Books is a bookshop. Every day, customers send messages. Where is my order? Can I return this book? How much does it cost? We'll fine-tune a small model to read each message, and say what the customer wants, and which book it's about.
key value Riverside Books a small bookshop Every day customer messages The task what do they want? which book? Our tool a small fine-tuned model
Let's recap. Pretraining is huge, slow, and expensive, and makes a base model. Fine-tuning is small, fast, and cheap, and makes a specialist. And we'll fine-tune a model for Riverside Books. Next, when to fine-tune, and when not to.
Key takeaways Pretraining: huge, done for you Fine-tuning: small and cheap Project: Riverside Books