Skip to main content
CookLLM logoCookLLM Docs
FundamentalsModel Architecture

Transformer LM

From token ids to next-token logits — building an overall mental model of the Decoder-only Transformer

Overview

The Transformer LM series answers one concrete question: when we call model(input_ids), what actually happens inside the model?

This series first establishes the overall forward pass of a Decoder-only Transformer, then takes apart the key interfaces — embedding, LM head, decoder block, residual stream, and so on. Attention, RoPE, RMSNorm, and SwiGLU are expanded on in later topics; here we first put them back into the data flow of a complete language model.

Chapter Contents

Learning Path

StageContentGoal
OverallFrom token ids to logitsSee clearly the inputs, outputs, shapes, and the training/inference fork point
Input/OutputEmbedding and LM HeadUnderstand how token ids enter the model and how hidden states become logits

References