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 · about 18 min to read

Play it as a journeyTutor comes with a plan

The library layer: PyTorch, Hugging Face and a free GPU

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 shows the tools that let you build that machine, and borrow a bigger one, in a few lines each.

Before you start. In The GPT Block you wrote a small GPT, a model that scores the next character, using only numpy. It had 54,707 weights, and training took 87 seconds on a laptop. From Autograd by Hand: autograd is the step that works out each weight’s slope, the direction to nudge it. From A LoRA Run: LoRA freezes the big weights and trains a small pair of matrices beside them. From The GPU (thousands of cores, and the memory that feeds them): a GPU is a chip with thousands of small cores that does many sums at once. From Tokens & Embeddings: a token is a piece of text a model reads, and a tokenizer cuts text into tokens.

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

  • The problem: your own code stops at 54,707 weights
  • Python setup: one folder of packages for each project
  • Tensor: a grid of numbers that remembers how it was made
  • Module: a block of weights with a forward method
  • Checkpoint and Hub: a trained model that you download by name
  • Fine-tuning in one call: PEFT and TRL
  • A free GPU: Colab or Kaggle
  • The GPT in PyTorch
  • Loading a model and reading its output
  • The SFT script

Terms it explains: From Transformer to LLM, virtual environment, tensors, module, checkpoint, Hub, SFT, Common mistakes, On a GPU, Save only the adapter, 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