Build your own GPT-2
Setup & orientation·2 min

Run the grader

0 / 2
# grade this stage (from your course directory)
npx theinference test --stage run-the-grader --watch

This is your first green check. It proves the loop works — edit, save, watch it grade — before you write any inference code. Every later step plugs into this exact loop, so it's worth landing the green here and watching how it feels.

The run / learn loop

You work in your own editor and terminal. The flow is:

  1. Log in (once): npx theinference login — approves in your browser, and passing stages then tick off here automatically
  2. Scaffold the course: npx theinference course start llm-inference ./llm-inference
  3. Install dependencies: cd llm-inference && npm install
  4. Run the grader in watch mode: npx theinference test --stage run-the-grader --watch

The grader executes your program through ./your_program.sh (which runs src/gpt2.ts), feeds it inputs, and compares the output to a reference. --stage runs everything up to the stage you're on — each lesson shows its exact command — so a green run means your stage is done.

What to do

Your task

Run the grader

Nothing to write — the setup command is already wired in src/gpt2.ts. Just run the grader and watch this step pass.

src/gpt2.ts
if (command === "setup") {
  console.log("theinference: toolchain OK");
  process.exit(0);
}
Keep the grader in a split pane
  • npx theinference test --stage <stage> --watch re-runs on every save — keep it open next to your editor, and bump --stage as you advance (each lesson shows its command).
  • Debug to stderr (console.error); the grader only reads stdout, so stray console.log will fail an exact-match check.
  • Steps unlock in order — with --stage set, a fully green run means your current stage is complete.
Fetch the weights now (~548 MB)

Most steps from Chapter 1 on need the real GPT-2 weights. The download script ships with your course — run it once from your course directory, while you read, so you're never blocked:

./scripts/fetch-weights.sh ./weights

It puts model.safetensors in ./weights/, where the grader expects it. Kick the download off in another terminal now.

How it's graded

Your program is run as ./your_program.sh setup. Its stdout must be exactly:

theinference: toolchain OK