Understanding How AI Language Models Work

Understand what a language model really does, from tokens and attention to alignment, well enough to explain it and judge it.

This course is for members

$9 unlocks every course in the library, this one included, plus a credit to build a topic of your own and at least 10 new courses every month.

What you will learn about Understanding How AI Language Models Work

The 7-day sprint
  1. A Language Model Is a Probability Machine. A language model assigns probabilities to sequences of words, and it generates text by repeatedly predicting the next piece and feeding its own output back in.
  2. Tokens, Not Words. Models do not read letters or words; they read tokens, subword pieces produced by an algorithm like byte pair encoding, and that choice explains many of their odd failures.
  3. Embeddings and Attention. Each token becomes a vector, and attention lets every position pull in information from other positions by matching a query against keys and then mixing the corresponding values.
  4. The Transformer Block, Stacked. A transformer is a stack of identical blocks, each combining multi-head self-attention with a position-wise feed-forward layer, plus an explicit injection of position information.
  5. Pretraining, Scale, and In-Context Learning. Pretraining on enormous text with next-token prediction, at large enough scale, produces a model that can be steered by examples in the prompt alone, with no gradient updates.
  6. Alignment After Pretraining. A pretrained model predicts plausible text, not helpful text, so a second training phase using human demonstrations and human preference rankings teaches it to follow intent.
  7. Evaluating and Governing What You Built On. Judging a language model means knowing what its scores can and cannot prove, and using a published risk framework instead of your own intuition about what could go wrong.
The 80/20: the 6 concepts that matter most
  • Autoregressive next-token prediction
  • Tokens and subword vocabularies
  • Attention with queries, keys and values
  • Scale, pretraining, and in-context learning
  • Alignment through human feedback
  • Confabulation and the limits of evaluation
The core idea, explained like you are 5

A language model is a next-piece predictor: it turns everything written so far into a probability for every possible next piece of text, picks one, adds it to the text, and repeats.

Then the quiz and the ladder

10 questions that correct you when you are wrong, and beginner, intermediate, advanced levels, each with a practical exercise.

Created Sep 13, 2026. No mistakes have been reported by learners.

Written from these sources