LATENT LIBRARY AI ENGINEERING Fine-TuningLanguage Models When, Why and How to Adapt a Modelto Your Task LATENT LIBRARY EDITORIAL

Fine-Tuning Language Models

When, Why and How to Adapt a Model to Your Task

Latent Library Editorial

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

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.

Get the full book