This book is licensed for the personal use of the buyer. Please do not share or resell the file. Short quotations with attribution are welcome.
The information in this book is provided for education. It is not legal, financial or other professional advice. Product and company names are used only to describe them and belong to their owners.
This is a free sample: the introduction and first chapter.
IntroductionIntroduction
Fine-tuning, continuing to train a pre-trained language model on your own examples, can turn a general model into a specialist: one that writes in your format, follows your conventions, handles your domain's vocabulary and does it all faster and more cheaply than a larger general model. It is also frequently unnecessary, expensive and risky when applied to problems that better prompts or retrieval would solve.
This book helps you decide when fine-tuning is the right tool, and then do it well. It starts with the alternatives and a decision framework, then covers preparing data, supervised fine-tuning, parameter-efficient methods such as LoRA, quantised training, preference tuning and distillation. It gives particular attention to evaluation, avoiding regressions, estimating costs and maintaining tuned models over time.
Examples are framework-neutral and focus on the decisions you will face in real projects.
How the book is organised
Chapters 1 to 9: what fine-tuning is, alternatives and a decision framework.
Chapters 10 to 20: data: collecting, writing, cleaning, formatting and splitting examples.
Chapters 21 to 33: training: supervised fine-tuning, settings, LoRA, quantisation, preference tuning and distillation.
Chapters 34 to 46: evaluation, regressions, safety, costs, deployment and maintenance.
Chapters 47 to 50: how fine-tuning changes a model, what belongs in the prompt, model judges and small specialists.
Chapters 51 to 56: templates and tokens, multi-turn and tool use, multilingual tuning, embedding models, experiment tracking and pipeline security.
Chapters 57 to 63: worked examples, common mistakes, team, plan and a checklist.
Chapter 1What Fine-Tuning Is
A pre-trained language model has learned general language patterns from huge amounts of text. Fine-tuning continues training on a smaller, targeted dataset so that the model's behaviour shifts towards your examples: their format, tone, task and vocabulary.
Fine-tuning changes the model's weights. The result is a new model version that behaves differently even with short prompts.
You have reached the end of the free sample. The full book continues with 62 more chapters, plus the appendices.