Skip to content

See how a language model turns text into a prediction

See how a language model turns text into a prediction.

Follow a prompt through a working model, from tokens to attention to next-word probabilities. Change the inputs, inspect the actual numbers, and understand what each step does. It all runs in your browser.

Start in the browser. Follow the equations and reproduce the measurements in Python when you want more depth.

A small, trained transformer runs here in your browser. Investigate its place prediction.

A real computation from our two-layer teaching model. Small enough to inspect every value; trained on a 25-token synthetic language.

Live computations. Downloadable weights. Reproducible code.

Inspect the evidence behind the model

Explore a specific concept.

Each experiment runs the teaching model with editable inputs and explains the computed result.

All experiments

Small by design.
Open to inspection.

Our 4,496-parameter transformer makes its calculations visible. The experiments use the same model, weights, and engine as the Model Explorer.

The browser engine is checked against an independent NumPy implementation to within 1e-9. Hand-written backpropagation is checked against finite differences.

This model learns a tiny synthetic grammar. It does not have the capabilities of a production LLM. Each investigation explains what its evidence supports; architecture comparisons show where larger models differ.

Prefer a structured read?

Build the foundations in order, or use the chapters as a reference beside an experiment.

Start with the foundations
Browse all 21 chapters

Foundations

Functions, gradients, networks, probability and tokens. Everything later is built from these.

  1. 1Functions, parameters and gradient descent30 min
  2. 2Neural networks and the multilayer perceptron35 min
  3. 3Backpropagation and optimizers40 min
  4. 4Probability, softmax and next-token prediction30 min
  5. 5Tokens and embeddings30 min

The transformer

Attention, the block, position, and the complete model.

  1. 6Attention45 min
  2. 7The transformer block40 min
  3. 8Position and rotary embeddings40 min
  4. 9The full model and its training loop35 min

Fast attention and inference

Why generation is memory-bound, and the designs that cut the cost.

  1. 10Generating text: the KV cache and inference cost35 min
  2. 11Grouped-query and latent attention35 min
  3. 12FlashAttention30 min
  4. 13Local, sparse and linear attention; state-space models45 min

Scaling the network

Experts and low-precision numbers.

  1. 14Mixture of experts40 min
  2. 15Floating point and quantization40 min

Training

Pretraining at scale, post-training and adaptation.

  1. 16Pretraining at scale40 min
  2. 17Post-training: instruction tuning, preferences and reinforcement learning50 min
  3. 18Adapting models: LoRA, QLoRA and distillation25 min

Systems

Prompting, retrieval, tools and agents.

  1. 19Prompting, retrieval, tools, agents and MCP40 min

Security and evaluation

The attacks and defenses, tied back to the papers, and how to measure any of it honestly.

  1. 20Attacks on language models and their defenses60 min
  2. 21Evaluating models and systems45 min

Spotted a mistake, a confusing explanation or a broken widget? Report a problem with this page

Methods & evidence · Run locally

Free for noncommercial use. Text CC BY-NC-SA 4.0, code PolyForm Noncommercial. Source on GitHub · How to contribute