How nanoGPT applies configuration overrides
The trainer starts with defaults. A small configuration script replaces those defaults with values from a Python file or a command-line flag.
Read the original configurator.py
Run a config file, or override one global
configurator.py is not imported. train.py and sample.py execute it, so its writes land in their global variables. An argument without an equals sign is a path. The file is printed and then run in that same global scope, which is how config/train_shakespeare_char.py replaces the defaults. An argument with an equals sign must look like --key=value. The key has to already exist, the value is parsed as a Python literal when it can be, and the type has to match the old value. A typo is an error, not a new setting. literal_eval reads numbers and bools. It does not run arbitrary code. The config file does.
Check your understanding
- What happens when you pass config/train_shakespeare_char.py?
- How could a --key=value flag override one variable?