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 115 of 120
Interview: LoRA and Training The deeper questions.
⏱ 2 min read ▶ Video at 2:54:20 🎓 Free
▶ starts at 2:54:20 The next questions go deeper. Interviewers want to know that you understand how LoRA works, and how to train well.
Deeper questions How LoRA works How to train well Question one. How does LoRA work? A good answer. LoRA freezes the original weights. It adds two small matrices, B and A, beside chosen layers. Their product is a low rank update, added to the layer's output. Only B and A are trained.
key value Freeze original weights Add small matrices B and A Update B × A, low rank Train only B and A
Question two. What are rank, and alpha? Rank is the inner size of B and A. A higher rank can learn more, but trains more parameters. Alpha scales the update. A common choice is alpha equals twice the rank.
key value Rank r inner size of B and A Higher r more capacity, more params Alpha scales the update Common alpha = 2 × r
Question three. What is QLoRA? It loads the base model in four bit precision, and trains LoRA adapters on top. It cuts memory by about four times, so big models fit on one GPU. Question four. Other ways to save memory? Gradient accumulation, and gradient checkpointing.
key value QLoRA 4-bit base + LoRA Saves about 4× memory Also gradient accumulation And gradient checkpointing
Prefer to watch? The full Fine-Tuning LLMs course is free All lessons in one video with animations, real code and chapters.
Watch free Here's a tricky one. Why does LoRA usually forget less than full fine-tuning? Pause, and think about it. The answer is C. The original weights are frozen, so the model's old knowledge stays intact.
Quick check
Why does LoRA usually forget less?
A. It trains longer B. It uses more data C. The original weights are frozen D. It uses a higher learning rate
Question six. What's the difference between SFT, and DPO? SFT copies example answers. DPO learns from pairs of a chosen, and a rejected answer, with no reward model. It usually comes after SFT, to polish style.
key value SFT copy good answers DPO chosen vs rejected No reward model needed Order SFT, then DPO
Let's recap. LoRA trains small matrices, beside frozen weights. Rank sets capacity, and alpha scales the update. QLoRA adds four bit loading. And DPO learns from preferences. Next, a code cheat sheet.
Key takeaways LoRA: B × A Rank and alpha QLoRA, DPO