Book

How to Fine-Tune an LLM

Data, LoRA, evaluation, and what it costs to serve

When fine-tuning is the wrong answer, and how to do it properly when it is the right one. Data, LoRA, training, honest evaluation, and what it costs to serve.

This book is planned but not yet written. The chapter list below is the outline, and it will fill in over the coming months. In the meantime the Python primer,So You Want to Be a Data Scientist, has its first three chapters live.

Before You Start

  1. 1When Fine-Tuning Is the Wrong AnswerThe decision tree that saves most teams a quarter of wasted work.
  2. 2Prompting vs RAG vs Fine-TuningWhat each one actually fixes, and why they are not alternatives.
  3. 3How Transformers Work, Enough to Debug ThemAttention, tokens, context, and the KV cache that dominates your bill.

The Data

  1. 4Building the DatasetFormat, volume, quality, and why a thousand good examples beat fifty thousand scraped ones.
  2. 5Instruction Tuning and Chat TemplatesGetting the format exactly right, which is where most attempts fail silently.

The Training

  1. 6LoRA and QLoRA ExplainedLow-rank adaptation from the linear algebra up, and how to pick the rank.
  2. 7Running the Training JobHyperparameters that matter, curves to watch, and when to stop.
  3. 8Preference TuningDPO and its relatives, when reward modelling is worth the trouble.

Proving It Works

  1. 9Evaluating a Fine-Tune HonestlyBuilding a real eval set, LLM-as-judge and its biases, regression testing.

Shipping

  1. 10Quantisation and ServingMerging adapters, GGUF and AWQ, throughput, latency, and cost per request.
  2. 11A Complete Worked ExampleOne domain, end to end, with every number reported.