Jump to ratings and reviews
Rate this book

A Hands-On Guide to Fine-Tuning Large Language Models with PyTorch and Hugging Face

Rate this book
Are you ready to fine-tune your own LLMs?

This book is a practical guide to fine-tuning Large Language Models (LLMs), combining high-level concepts with step-by-step instructions to train these powerful models for your specific use cases.

Who Is This Book For?

This is an intermediate-level resource—positioned between building a large language model from scratch and deploying an LLM in production—designed for practitioners with some prior experience in deep learning.


If terms like Transformers, attention mechanisms, Adam optimizer, tokens, embeddings, or GPUs sound familiar, you’re in the right place. Familiarity with Hugging Face and PyTorch is assumed. If you're new to these concepts, consider starting with a beginner-friendly introduction to deep learning with PyTorch before diving in.

What You’ll Learn
Load quantized models using BitsAndBytes.
Configure Low-Rank Adapters (LoRA) using Hugging Face's PEFT.
Format datasets effectively using chat templates and formatting functions.
Fine-tune LLMs on consumer-grade GPUs using techniques such as gradient checkpointing and accumulation.
Deploy LLMs locally
in the GGUF format using Llama cpp and Ollama.
Troubleshoot common error messages and exceptions to keep your fine-tuning process on track.


This book doesn’t just skim the surface; it zooms in on the critical adjustments and configurations—those all-important "knobs"—that make or break the fine-tuning process.
By the end, you’ll have the skills and confidence to fine-tune LLMs for your own real-world applications. Whether you’re looking to enhance existing models or tailor them to niche tasks, this book is your essential companion.

Table of Contents
Frequently Asked Questions (FAQ)
Chapter 0: TL;DR
Chapter 1: Pay Attention to LLMs
Chapter 2: Loading a Quantized Base Model
Chapter 3: Low-Rank Adaptation (LoRA)
Chapter 4: Formatting Your Dataset
Chapter 5: Fine-Tuning with SFTTrainer
Chapter 6: Deploying It Locally
Chapter -1: Troubleshooting
Appendix A: Setting Up Your GPU Pod
Appendix B: Data Types' Internal Representation

520 pages, Kindle Edition

Published January 25, 2025

10 people are currently reading
10 people want to read

About the author

Daniel Voigt Godoy

5 books6 followers
Daniel Voigt Godoy is an Amazon best-selling author who has self-published a series of technical books used as textbooks in universities in the United States and Spain.
In the last 25 years, he had many jobs—developer, data scientist, teacher, writer—but he's none of them. After figuring out his own path, he decided to share his experience and insights with others in his upcoming book "You're Not Your Job: Going Above and Beyond for Yourself."

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
3 (100%)
4 stars
0 (0%)
3 stars
0 (0%)
2 stars
0 (0%)
1 star
0 (0%)
Displaying 1 - 2 of 2 reviews
Profile Image for Jin Shusong.
79 reviews1 follower
September 23, 2025
Following the guide in this book, one can easily fine-tune his own LLM. Note that multiple-gpu fine-tuning is not covered.
Displaying 1 - 2 of 2 reviews

Can't find what you're looking for?

Get help and learn more about the design.