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 22 min to read

Play it as a journeyTutor comes with a plan

Sampling and What Scale Buys

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 makes the small one write, then counts the distance to a big one: the last of six lessons that build a small GPT from scratch.

Before you start. In The GPT Block you trained a small GPT, the kind of model built in the last two lessons, which writes one character at a time. Trained on 3,000 short returns-desk replies, it scores each of the 51 characters that could come next. From The Maths Floor, Part 2: Probability, Softmax and Temperature: softmax turns scores into chances that add up to 1. Sampling draws one outcome in proportion to its chance. Temperature divides every score first. From Tokens & Embeddings: a real model reads tokens, chunks of text about four characters long. A weight is one number inside the model. fp16 stores each weight in 2 bytes, so 7 billion weights take 14 GB. From The GPU (thousands of cores, and the memory that feeds them): an A100 is a GPU chip for AI work, and it reads its memory at 2 TB/s.

Lesson 64 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

  • May 2018, Menlo Park: the words a model should never pick
  • The prompt: the start of a reply, and a loop that writes the rest
  • Greedy decoding: always the top score, and one reply for every customer
  • Temperature: the dial, on a model you trained
  • Top-k sampling: cut the tail, then draw
  • From 51 characters to 32,000 tokens: the same loop, much bigger
  • Training compute: 6 sums per weight per token, and 21 years of one A100
  • What scale buys, and what it does not
  • Five scores and one dice roll
  • The trainee’s 200 replies, read slowly
  • What the bigger desk’s training cost
  • All of it in code

Terms it explains: From Transformer to LLM, prompt, greedy decoding, top-k sampling, training tokens, training compute, 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