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 8 of 120
The Hugging Face Hub Models you can download.
⏱ 2 min read ▶ Video at 12:03 🎓 Free
▶ starts at 12:03 The Hugging Face Hub is where we'll find our models. Think of it as a giant library, where every book is a model, ready to borrow.
A giant library Every book is a model Ready to borrow Every model on the Hub has a name, in two parts. First the owner, then a slash, then the model. For example, Hugging Face TB slash Small LM two, one three five M. The first time you use a model, it downloads, and is saved on your computer. After that, it loads from there.
key value Format owner/model Example HuggingFaceTB/SmolLM2-135M First use downloads it After that loads from your disk
Every model has a page, called a model card. Read it before you use a model. It tells you what the model was trained on, what it's good at, and its licence. The licence says what you're allowed to do with it, like use it in a business.
key value Model card the model's web page Training data what it learned from Good at what it's for Licence what you may do with it
Prefer to watch? The full Fine-Tuning LLMs course is free All lessons in one video with animations, real code and chapters.
Watch free Every model comes with a config. It describes the model's shape. Auto config loads it, without loading the weights. We print a few settings. Run it. It's a llama style model, with thirty layers. Each token becomes a list of five hundred and seventy six numbers. It knows about forty nine thousand tokens. And it can read over eight thousand tokens at once.
app.py python Copy
from transformers import AutoConfig
config = AutoConfig.from_pretrained( "HuggingFaceTB/SmolLM2-135M" )
print ( "Model type: " , config.model_type)
print ( "Layers: " , config.num_hidden_layers)
print ( "Hidden size: " , config.hidden_size)
print ( "Vocabulary: " , config.vocab_size)
print ( "Max context: " , config.max_position_embeddings) Output
Model type: llama
Layers: 30
Hidden size: 576
Vocabulary: 49152
Max context: 8192 Let's recap. Models on the Hub are named owner slash model. Always read the model card, and its licence. And the config describes the model's shape. Next, let's actually use a model, with pipeline.
Key takeaways owner/model Read the model card AutoConfig