§7.9–7.10Conclusions & Chapter Summary

Part III pp. 127–128 · ~2 min read

  • preference fine-tuning

The judge has scored the responses; the assistant works. This short closer marks the end of the book’s main arc — data → attention → architecture → pretraining → two kinds of fine-tuning — and points at the one step it leaves open.

7.9 Conclusions — what comes after instructions

The book covered the most essential steps, but one optional stage can follow instruction fine-tuning: preference fine-tuning — particularly useful for customizing a model to better align with specific user preferences. An instruction-tuned model answers correctly; a preference-tuned model answers correctly in the way its users prefer — tone, style, and choices between equally-valid responses. (Implementing it is beyond the book’s scope — a deliberate open door.)

Foundation modelpretraining · ch2–5 ✓Instruction followerinstruction fine-tuning · ch7 ✓Preference-alignedpreference fine-tuning · optional← beyond the book
The full staircase. The dashed step — aligning with user preferences — is the modern frontier the book hands you the prerequisites for.

7.10 Summary

  • Instruction fine-tuning adapts a pretrained LLM to follow human instructions and generate desired responses.
  • Data preparation: download an instruction-response dataset, format the entries (Alpaca template), split into train/validation/test.
  • Batches come from a custom collate function that pads dynamically, builds shifted target IDs, and masks padding with −100.
  • The starting point is a pretrained GPT-2 medium (355M) — small models lack the capacity for high-quality instruction-following.
  • Training uses a loop similar to pretraining — same loss, same optimizer, new data.
  • Evaluation: extract test-set responses and score them with another LLM (an 8B-parameter Llama via Ollama), averaging for a quantitative result.

The journey, complete

Every promise from chapter 1’s roadmap is kept: tokenizers and embeddings (ch2), attention from dot products to multi-head (ch3), the GPT architecture (ch4), pretraining and borrowed weights (ch5), a classification specialist (ch6), and an instruction-following assistant (ch7) — every line of it built from scratch and explained. What remains on this site are the book’s appendices: the PyTorch crash course (A), training-loop refinements (D), and LoRA (E).

📝 Check yourself: the journey, complete

0 / 4
  1. 1.What is preference fine-tuning, and where does it sit in the pipeline?

  2. 2.Across chapters 5–7, what stayed constant while everything else changed?

  3. 3.The instruction-tuned model is evaluated at ~50 (hypothetically) by the Llama judge. Which statement is the fairest interpretation?

  4. 4.Looking back over the whole book: which chapter's component would you change to give the assistant a larger working memory (longer conversations)?