📖 How to Build and Fine-Tune a Small Language Model

A Step-by-Step Guide for Beginners, Researchers, and Non-Programmers

📚 Buy PDF 📦 Buy Paperback 💻 Download Code

How to Build and Fine-Tune a Small Language Model

Welcome! Below are the Google Colab notebooks for each chapter.

© 2025–2030 J. Paul Liu. All rights reserved.

This material is provided exclusively for readers of How to Build and Fine-Tune a Small Language Model. Please do NOT redistribute these Colab notebooks.

Chapter 2 – Let's Build GPT from Scratch

Open Colab Notebook

Chapter 3 – Quick Start: Fine-Tune Your First Model

Open Colab Notebook

Chapter 4 – Dataset Preparation

Open Colab Notebook

Chapter 5 – Model Architecture & Configuration

Open Colab Notebook

Chapter 6 – Training Loop & Monitoring

Open Colab Notebook

Chapter 7 – Evaluation & Benchmarks

Open Colab Notebook

Chapter 8 – Pre-training Your Own Language Model from Scratch

Open Colab Notebook

Chapter 9 – Stage 2: Supervised Fine-Tuning (SFT)

Open Colab Notebook

Chapter 10 – Stage 3: Direct Preference Optimization (DPO)

Open Colab Notebook

Chapter 11 – Production Deployment

Open Colab Notebook

Chapter 12 – Complete Production Projects & Ethics

Open Colab Notebook

Chapter 13 – Appendices

Open Colab Notebook

Before You Begin

  1. Visit Google Colab and make sure you can access Colab.
  2. If a notebook opens as plain text instead of inside Colab, choose Open With → Google Colab.
  3. If you don't see the Google Colab app, click Connect more apps.
  4. If your browser doesn't show "Open with Google Colab", download the .ipynb file and upload it manually from within Google Colab.