nanoGPT’s Shakespeare training configuration

The Shakespeare experiment uses the same trainer as larger models. A short Python config sets the dataset, context length, and size of the network.

Read the original config/train_shakespeare_char.py

A laptop-sized Shakespeare GPT

This file is the cozy run. It writes to out-shakespeare-char, trains on shakespeare_char, and shrinks the network to 6 layers, 6 heads, and width 384, with a context of 256 characters and a batch of 64. Dropout is 0.2. The learning rate is 1e-3 for 5000 steps, decaying to 1e-4, with a short warmup. Checkpoints are kept only when validation improves. None of this runs by itself. It is a list of assignments waiting to be executed inside train.py.

Check your understanding

  • Which settings make this "character Shakespeare" instead of GPT-2 scale?
  • Where is the dataset path set?

Next chapter · How a config lands

Based on Andrej Karpathy’s nanoGPT, licensed under the MIT license.