Highlights

Contents

INSIDE THE DECODER · UNIT IIITrainingthe ModelHow text becomes a loss, an update,and a useful next-token prediction.corpus + tokenizerinput / targetFinch-24 decoderlogitscross-entropylossbackward + AdamWupdated weightsthe next batchuses new weightscheckpoint → prompt → generated textA HAND-DRAWN FIELD GUIDE · CHAPTER 3
Before we start

How to read this chapter

Drawing a decoder does not explain how it learns. This chapter follows prediction, error, gradients, updates, evaluation, and generation.

Pretraining learns a next-token distribution from text before task-specific adaptation. Begin with the forward pass, then follow the loss backward to the parameters. Explain why each operation is needed before reading its formula. Later parts show how to resume training, interpret learning curves, compare experiments, and choose a generation policy. The interview exercises test those explanations.

Each part ends with an “In one breath” recap. The interview page has questions, graded exercises, and worked solutions; try the reasoning before reading the answer.

The running example

Meet Finch-24 again

Finch-24 keeps the modern guide’s architecture fixed. It is an illustrative configuration; optimizer settings and toy losses are not measured results. Real-model comparisons use the original Llama 3 8B release.

Setting Symbol Finch-24 What it controls
Vocabulary VV 32,000 Possible token IDs
Hidden width dd 512 Features per token
Decoder blocks LL 8 Depth
Query heads HH 8 Attention queries
Key/value heads HkvH_{kv} 2 Shared key/value groups
Head width dhd_h 64 Features per head
SwiGLU intermediate width ff 1,536 Feature expansion
Maximum context Tmax⁡T_{\max} 4,096 Supported training window
Rotary base θ\theta 10,000 RoPE frequencies
Normalization Pre-norm RMSNorm Block and final normalization
Norm epsilon ε\varepsilon 10−510^{-5} Denominator floor
Bias parameters None Projection convention
Output head Tied Shares the input embedding
Unique parameters PP 40,509,952 Learned scalar values

Batch size is the number of sequences processed together. Sequence length is the number of input positions in each sequence. A microbatch is one group processed in a forward and backward pass; gradient accumulation combines groups before an update. The input and its targets are the same sequence offset by one position.

The map

What is inside

Ten parts follow the supplied topic order. First finish the decoder, then construct its examples, differentiate its loss, run and evaluate training, and generate text. The final part reconciles the complete pipeline and every Finch-24 parameter.

THE TRAINING CHAPTER: TEN PARTS, ONE COMPLETE MODEL1. features2. output3. examples + loss4. optimizer5. precision6. resume + loop7. evaluation8. experiments9. decoding10. whole pipelineforward computation → learn parameters → measure results → generate
  1. 01Feature computation, now seen from trainingSections 1 to 2. Training must differentiate feature transformation as well as attention.
  2. 02Turning a hidden vector into predictionsSections 3 to 6. The final representation must become a prediction.
  3. 03Giving the decoder something to learnSections 7 to 10. Text supplies its own next-token targets.
  4. 04Choosing the parameter updateSections 11 to 14. A gradient gives a direction, not a complete update rule.
  5. 05Keeping learning inside numerical limitsSections 15 to 18. Training needs sensible starting values and usable arithmetic.
  6. 06Running and resuming the experimentSections 19 to 20. Resuming training requires more than the current weights.
  7. 07Measuring the predictorSections 21 to 23. Fitting seen text differs from improving on new text.
  8. 08Comparing experiments fairlySections 24 to 26. A favorable run can reflect luck or budget differences.
  9. 09Turning predictions into textSections 27 to 32. Generation uses choices the model has not seen in advance.
  10. 10The complete training-to-generation pipelineSections 33 to 35. The pipeline connects text, learning, evaluation, and generation.
  11. +Interview prepInterview question bank, graded exercises and worked solutions.