The two tables. One row of three numbers per token, one table per window position. Fetch a row from each, add them, and those three numbers are the model’s whole input.
The scoreboard. Three weights and a bias per token, 116 numbers, that turn the input into a score for every token. With the 174 in the tables, that is the 290.
Scores become shares. On the CoCo they add up to 256, and one drawn byte picks the next token.
One update. The prediction error is predicted probability minus target probability. For an output weight, multiply that error by the learning rate and the corresponding context value, then subtract the result from the weight. Training also updates the biases and the embedding rows used by the example.
I chose twenty epochs for the live demonstration: 1,160 training steps. The checkpoint scores show why I stopped there; the assembly shows what each step costs.
Twenty times through
An epoch is one pass through the 58 examples. The demonstration trains for twenty epochs. At a few points along the way I stopped the reference model on the Mac, drew 200 names from it, and scored them. Here is what came out, two draws per checkpoint, with the loss the training loop reported at that point:
Epoch
Loss
Two of the 200 draws
0
3.26
II APPLE COMMODORE ACORN 64 II / ARCHIMEDES ARCHIMEDES ARCHIMEDES 400 SINCLAIR COLOR
1
3.04
II APPLE BBC 64 100 COMMODORE / ARCHIMEDES ARCHIMEDES AMIGA
5
2.42
COMPUTER ARCHIMEDES / ATARI ATARI
20
1.83
SINCLAIR AMIGA / COMMODORE ATARI
60
1.27
SINCLAIR BBC / COMMODORE 64
The loss falls the whole way. It measures how wrong the guesses are, and by that measure epoch 60 is the best model in the table. Post one showed why I stopped at twenty anyway: at sixty, 143 of the 200 draws were names from the training data, word for word.
Repeating a token goes first. At epoch 0, 83 of the 200 draws say the same word twice, ARCHIMEDES ARCHIMEDES ARCHIMEDES. After one pass it is 70. After five, 19. At twenty, 3.
The shape comes second. I wrote down what a name looks like before I drew a single sample: two to four tokens, and the first one is a maker, one of ACORN, APPLE, ATARI, COMMODORE, SINCLAIR or TANDY. That is a crude test; TANDY TANDY TANDY passes it. I wrote it before drawing anything so it could not be bent toward a result. One draw in 200 passes it at epoch 0, 12 after one pass, 109 after five, 197 at twenty. At sixty epochs, 199 of 200 draws pass this shape test, but far fewer are new names.
Copying comes last. Nothing at epoch 0 or epoch 1 is a training name. At five, 5 of the 200 are. At twenty, 18. At sixty, 143. Further training increased the probabilities of the observed continuations, making complete training names more likely to be sampled.
Epoch
Repeats a token
Right shape
In the training data
New and the right shape
0
83
1
0
1
1
70
12
0
12
5
19
109
5
104
20
3
197
18
179
60
0
199
143
56
I wanted new names with the right shape, so I scored that separately from loss. That column peaks in the middle. Loss rewards higher probability for the training targets, even when further training makes the output less useful for inventing names. I ran a longer sweep out to 120 epochs, and the useful band is about 13 to 25; fifteen scores 93% against twenty’s 90%. Twenty is the number the CoCo build has baked in, so the post and the machine agree.
What twenty epochs cost
I kept the model at 290 parameters and the run at 20 epochs to fit the demonstration on a stock CoCo 1.
Each example takes 261 multiplies. With 58 examples per pass and 20 passes, training takes 302,760 multiplies. The full run executes 15.8 million instructions. The calculation and the emulator at the 1981 clock rate put training at a little over a minute. I have timed the full training run several times on physical hardware, with the same result.
Inference needs 2,516 bytes for the forward pass, sampling and the 580 bytes of weights. Training requires another 730 bytes for its update code, training examples and progress display. Those additional bytes are not needed for inference. A released set of weights likewise does not include the entire system used to train it.
The model uses fixed-point numbers: integers that stand for fractions. Updates can lose fractional precision, a form of quantization. The processor details below show where that precision goes and how the CoCo executes the update.
Next post: how prompts, model size and training data affect the output.