Choosing the objective and data for language-model pretraining

← Back to Blog & Articles

Parts I through III built a decoder-only Transformer and derived every piece of its forward pass; this discussion, opening Part IV (Training at Scale), turns that architecture into a trained model.

Parts I through III built a decoder-only Transformer and derived every piece of its forward pass; this article, opening Part IV (Training at Scale), turns that architecture into a trained model. It restates the causal language modeling objective from the companion book (Probability and Information Theory for Language Modeling) in the exact form minimized at every training step, derives the gradient that objective sends into the network’s final layer, and works through the engineering pipeline — crawling, filtering, deduplicating, mixing, and packing a training corpus — that turns raw text into the batches a Transformer consumes. By the end you will be able to derive the softmax-cross-entropy gradient from first principles, explain precisely why MinHash and locality-sensitive hashing make near-duplicate detection tractable at web scale, derive the block-diagonal attention mask packed training requires, and implement a complete pretraining loop, from packed sequences to a falling loss curve, for a toy GPT.

Continue with the book

Explore the full treatment, worked examples, and exercises in LLMs Derived.


Companion article for LLMs Derived, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.

Scroll to Top