From a training corpus to a checkpoint 00:00:01 One missed word moves a checkpoint At the training bench a rare target token was given one chance in four. The next checkpoint is supposed to make observed continuations less surprising. Before Nila celebrates a lower loss, she needs to know which positions contributed to it. Language-model pretraining repeatedly predicts held-out target tokens from their prefixes. The training loop shifts inputs and targets, masks padding or other excluded positions, measures the negative log-probability of the targets and backpropagates gradients. An optimizer uses those gradients and its running state to update the weights. Validation measures performance on data withheld from those updates. Mark the input and its next-token target one position apart. Padding can be present for batching without contributing to the loss. Four microbatches can accumulate gradients before a single optimizer update. 00:00:54 Score the shifted targets Two real target tokens remain after padding positions are excluded. The dataset manifest fixes the sampling mix. Compute target loss and differentiate through the model. Inspect the mask before interpreting a strangely low loss. Update weights and the schedule once per effective batch. Persist the step and optimizer state. Evaluate on untouched data under the same masking rule. Record both training and validation loss against tokens processed. Average over unmasked target positions. Use the same tokenizer when comparing perplexity. 00:01:29 What survives an interruption? Cross-entropy averages negative log probability across the evaluated target tokens. Exponentiating the mean natural-log loss gives perplexity. Tokenizers, masking rules and evaluation distributions affect comparisons. If the model assigns the true next token probability 0.25, that target contributes about 1.386 nats. A single such target has perplexity four. Accumulate gradients over microbatches when the full effective batch will not fit. Scale or normalize them consistently and update the optimizer and schedule at the intended step. Evaluation batches must not update the weights. Accumulating four eight-example microbatches gives 32 examples per optimizer step on one worker when every example is counted equally. Track the sampling weight of each corpus, deduplicate across the training and validation boundary and keep a domain holdout. A warmup and subsequent learning-rate decay change update sizes across steps. Save the scheduler, optimizer and random state when resuming. If textbooks form 10 percent of files but 45 percent of tokens, sampling files uniformly and sampling tokens uniformly produce different mixtures. Plot domain validation loss beside aggregate loss before changing the mix. Inspect both curves. A falling training loss with a rising held-out loss can signal overfitting or distribution mismatch. A sudden change after resume can indicate missing optimizer state, learning-rate position or data ordering. Continued pretraining adapts next-token statistics on a domain corpus, supervised tuning teaches desired responses, and retrieval supplies changeable source facts at request time. 00:03:22 Can the validation score still be trusted? Training loss drops after an accidental copy of the evaluation set enters training. What happened to the validation claim? Contaminated examples cannot estimate behavior on genuinely unseen data. Rebuild the split and reevaluate. Preserve the tokenizer, data order, optimizer and schedule with the checkpoint. Then keep validation examples independent. an accidental copy entering training can lower the number while destroying the claim that it measures generalization.