Raghuram Shankar
← Language Modelling

Part 1 · Background

Deep background: what a model of text even is

Suppose you want to assign a probability to an entire sentence. Directly tabulating P(the whole sentence) is hopeless: there are more possible 50-word English sentences than atoms in the observable universe, so no corpus could ever list them. The escape is the chain rule of probability, which is an identity, not an approximation:

P(x₁, …, xT) = ∏t=1..T P(xt | x<t)

The joint probability of a sequence factorizes exactly into a product of next-token probabilities. That single line is why modern language modelling is possible: instead of learning an astronomically large table, you learn one conditional distribution — what comes next, given everything so far — and apply it repeatedly. A model that is good at that one prediction is, by the identity above, a model of all text.

bytesraw text
→
tokensBPE merges
→
transformerattention + FFN
→
P(next token)a vector over the vocabulary
The entire pipeline. Every part of this page is one of these four boxes, or the machinery needed to fit the third one at scale.