Code: Build your own GPT in Jennifer
Build your own GPT in Jennifer: the code
The programs behind the slides. They need no server, no network and no decks, and run with Jennifer 0.27.0 from this folder. The engine and the model are copies of demo-micrograd (v8/autograd.j) and demo-microgpt.
neuron.j: one neuron,tanh(x * w + b), on the tape: prints the nodes in the order they were appended, runsbackwardand checks every gradient by hand ("Every number is a node", "The tape is already sorted"). Run:jennifer run neuron.jsample.j: loads a checkpoint and generates names ("Train once, sample often", "Run it"). Run:jennifer run sample.j --load 32k1000.json --samples 5train.j: trains the GPT with Adam, one spawned worker per name in a batch, saves a checkpoint and samples from it ("The loss", "Training on every core"). It trains oninput.txt(one name per line) when there is one, else on a built-in list of about 50 names, and writesmodel.jsonhere. Run:jennifer run train.j --steps 50 --batch 8 --save model.jsonautograd.inc.j,model.inc.j,checkpoint.inc.j: the engine, the model and the checkpoint formats, included by the programs above.32k1000.json: a checkpoint trained on the 32,033 names of the makemore data set.
jennifer run sample.j --help and jennifer run train.j --help list every flag.
| File | Size | |
|---|---|---|
| 32k1000.json | 32.9 KiB | raw |
| LICENSE | 899 B | raw |
| README.md | 1.4 KiB | raw |
| autograd.inc.j | 13.1 KiB | raw |
| checkpoint.inc.j | 4.9 KiB | raw |
| model.inc.j | 13.1 KiB | raw |
| neuron.j | 1.2 KiB | raw |
| sample.j | 1.9 KiB | raw |
| train.j | 8.2 KiB | raw |