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 118 of 120
Final Quiz Test yourself.
⏱ 2 min read ▶ Video at 2:58:42 🎓 Free
▶ starts at 2:58:42 Let's test what you've learned, with a final quiz. Five questions. Pause before each answer, and really think about it.
A final quiz Five questions Pause and think Question one. In LoRA, which weights are trained? Pause, and think about it. The answer is B. Only the small adapter matrices are trained. The original weights stay frozen.
Quick check
In LoRA, which weights are trained?
A. All of them B. Only the small adapter matrices C. Only the embeddings D. Only the last layer
Question two. Labels of minus one hundred are used for which tokens? Pause, and think about it. The answer is A. The prompt tokens, so the loss is only computed on the answer.
Quick check
Which tokens get the label -100?
A. The prompt tokens B. The answer tokens C. Padding only D. None
Question three. Training loss falls, but eval loss starts rising. What's happening? Pause, and think about it. The answer is C. The model is overfitting, memorising the training data.
Quick check
Train loss ↓, eval loss ↑. What is happening?
A. Underfitting B. A bug in the data C. Overfitting D. Nothing, it is fine
Prefer to watch? The full Fine-Tuning LLMs course is free All lessons in one video with animations, real code and chapters.
Watch free Question four. Your fine-tuned model ignores the format, when you use it. What should you check first? Pause, and think about it. The answer is D. That you use the same system message, and chat template, as in training.
Quick check
The model ignores the format in use. Check first?
A. The GPU B. The learning rate C. The rank D. Same system message and template
Question five. What does DPO need, for each example? Pause, and think about it. The answer is B. A prompt, a chosen answer, and a rejected answer.
Quick check
What does DPO need for each example?
A. A prompt and one answer B. A prompt, chosen and rejected answers C. A reward score D. Only prompts
Well done. If you got most of those right, you really understand fine-tuning. If not, go back to those lessons. Next, what to learn next.
Key takeaways LoRA trains adapters -100 hides the prompt Same template in use