Causal Language Modeling › Causal Language Modeling

Michael BrenndoerferUpdated July 7, 20253 min read
Language AI HandbookAll chapters
Part 22 of 67Pre-training Objectives
Chapter 155Causal Language Modeling › Causal Language Modeling
Reading section 1 of 13 · Causal Language Modeling · 3 minSection 1 of 13 · 3 min

Book contents

Section 1 of 13 · 3 min read

Causal Language Modeling › Causal Language ModelingOne section · Sections in this chapter1 / 13 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Language models learn to predict the next word. This simple objective, applied at massive scale, has produced the most capable AI systems ever built. GPT-4 and Claude, along with LLaMA, share this foundation with virtually every modern generative model: given a sequence of tokens, predict what comes next.

Causal Language Modeling (CLM) is the formal name for this training objective. The "causal" refers to the direction of information flow: predictions depend only on past tokens, never on future ones. This constraint mirrors how humans produce language, word by word, and makes the learned model directly usable for text generation without any modifications to the architecture at inference time.

CLM derives its training signal directly from raw text. You don't need labeled data, annotated categories, or hand-crafted features. Every piece of raw text is automatically a supervised learning example: the input is a prefix, and the label is the next token. This means the entire internet, all books ever digitized, every line of code ever written can be converted into training signal at zero additional annotation cost. The web itself becomes a teacher.

Think of it this way: every time a model reads the phrase "The Eiffel Tower is located in," it is tested on whether it predicts "Paris" as the next token. Every time it reads import numpy as np\nimport, it is tested on whether it knows common Python libraries. Every sentence in every document becomes a series of prediction problems, and the model that learns to solve all of them must, necessarily, have learned a great deal about how language works.

The simplicity of the objective also means it generalizes remarkably. A model that learns to predict text must represent grammar, factual knowledge, reasoning patterns, and even emotional tone, because all of these factors influence what word comes next. CLM is in this sense a universal objective: it forces the model to internalize whatever statistical regularities are needed to predict the next token accurately, across all contexts and all domains present in the training corpus.

In this chapter, we'll unpack the mathematics behind CLM, understand why it works so well, implement the loss function from scratch, and explore the training data and scaling properties that have driven recent breakthroughs.