Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 06 · AI · GPT, built from scratch · with code: Python · about 24 min to read

Play it as a journeyTutor comes with a plan

The Bigram Model

From Transformer to LLM
From Transformer to LLM · Open board

The From Transformer to LLM board draws the machine that fills in the next blank. This lesson builds the smallest one: the second of six lessons that end with a small GPT built from scratch.

Before you start. A weight is one adjustable number inside a model. Its slope says how much the loss, the model’s wrongness, moves if you nudge that weight. Training nudges every weight a little against its slope, over and over. In Autograd by Hand you built code that finds every slope automatically, by remembering how each number was made and walking that record backwards. From The Maths Floor, Part 2: Probability, Softmax and Temperature: a probability is a share between 0 and 1, the shares add to 1, and sampling draws an outcome in proportion to its share. Also from The Maths Floor, Part 2: Probability, Softmax and Temperature: softmax turns a list of scores into probabilities. From Tokens & Embeddings: every piece of text gets an id, and an id can pick one row out of a table of numbers.

Lesson 60 of 83 in AI

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 1913, St Petersburg: Markov counts the pairs in a poem, and finds the bigram
  • 1948: Shannon writes with a book, sampling the bigram model
  • The returns desk’s tally sheet: a bigram model is a table of counts
  • Likelihood: scoring the tally sheet by the chance it gave the real text
  • Smoothing: one empty cell makes the loss infinite
  • The tally sheet as one weight matrix: cross-entropy and gradient descent
  • Why a weight matrix, if counting was free
  • Where the 3,000 replies come from
  • The day the chances multiply to nothing
  • The slope of one cell
  • A step on 4,096 pairs
  • All of it in code

Terms it explains: From Transformer to LLM, bigram, bigram model, likelihood, average negative log-likelihood, smoothing, cross-entropy, alignment, autoregressive, base model, Chinchilla, decoder-only, distribution, emergent ability, in-context learning, logits, next-token prediction, parameters / data / compute, pretraining, scaling laws, self-supervised.

Related papers

Review AI