Build an LLM from Scratch 7: Instruction Finetuning @SebastianRaschka
Build an LLM from Scratch 7: Instruction Finetuning  @SebastianRaschka
Uploaded April 2025 | Updated September 2026, 2 weeks ago
Links to the book:
- amzn.to/4fqvn0D (Amazon)
- https://mng.bz/M96o (Manning)

Link to the GitHub repository: github.com/rasbt/LLMs-from-scratch

This is a supplementary video explaining how to instruction finetune an LLM.

00:00 7.2 Preparing a dataset for supervised instruction finetuning
15:37 7.3 Organizing data into training batches
39:17 7.4 Creating data loaders for an instruction dataset
46:44 7.5 Loading a pretrained LLM
54:25 7.6 Finetuning the LLM on instruction data
1:14:20 7.7 Extracting and saving responses
1:23:56 7.8 Evaluating the finetuned LLM

You can find additional bonus materials on GitHub

Generating a Dataset for Instruction Finetuning, github.com/rasbt/LLMs-from-scratch/tree/main/ch07/03_model-evaluation

Direct Preference Optimization (DPO) for LLM Alignment, github.com/rasbt/LLMs-from-scratch/tree/main/ch07/04_preference-tuning-with-dpo

Building a User Interface to Interact With the Instruction Finetuned GPT Model, github.com/rasbt/LLMs-from-scratch/tree/main/ch07/06_user_interface

Evaluating Instruction Responses Using the OpenAI API and Ollama, github.com/rasbt/LLMs-from-scratch/tree/main/ch07/03_model-evaluation
Build an LLM from Scratch 7: Instruction FinetuningBuild an LLM from Scratch 6: Finetuning for ClassificationL8.7.2 OneHot Encoding and Multi-category Cross Entropy   Code ExampleL15.2 Sequence Modeling with RNNsL18.6: A DCGAN for Generating Face Images in PyTorch   Code ExampleL7.0 GPU resources & Google ColabScaling PyTorch Model Training With Minimal Code ChangesL8.5 Logistic Regression in PyTorch   Code ExampleL14.1: Convolutions and Padding13.0 Introduction to Feature Selection (L13: Feature Selection)Build A Reasoning Model (From Scratch), Page 198L12.0: Improving Gradient Descent-based Optimization   Lecture Overview
Sebastian Raschka |

Build an LLM from Scratch 7: Instruction Finetuning

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER