Language modeling

Wiki chapters and blog posts about Language modeling.

Wiki

Information Theory Refresher: Entropy, Cross-Entropy and KL Divergence

Entropy measures how surprising a distribution is on average, cross-entropy is the cost of coding data from p with a code built for q, and KL divergence is the excess over the optimum. A language model's training loss is cross-entropy; perplexity is its exponential.

Intermediate 11 min read

From Language Modeling to Next-Token Prediction

Language modeling estimates the probability of a text and uses the chain rule to split it into a product of "predict the next token given the prefix"; training uses cross-entropy, evaluation uses perplexity, and the causal mask hides future tokens.

Beginner 13 min read

Tokenizers and Embeddings: BPE, Vocabulary Size and the Embedding Table

An LLM only processes integers: a tokenizer splits text into tokens with a subword algorithm such as BPE and maps them to ids, then each id is looked up in a vocabulary-size by hidden-size embedding table. Vocabulary size trades off sequence length, parameters and long-tail coverage.

Beginner 33 min read

Blog posts

Scaling Laws for Neural Language Models

OpenAI's 2020 paper trained Transformers of 768 to 1.5 billion parameters on WebText2 and found that loss falls as a power law in parameters, data and compute, almost regardless of shape. At a fixed budget, grow the model first (size ∝ compute^0.73). A breakdown that checks the numbers.

Paper notes arXiv 2020

Topics