HeyMSK
Chapter 10 of 10

Understand the model’s limits

Our model has limited room for text and has only practised addition. Let's try those limits.

How much text fits?

The context window is the amount of text the model can use at once. Ours has 32 token slots. The start marker uses one, each character uses another, and the answer needs room too.

5 of 32 slots used by the start marker and your input.

27 slots remain for generated tokens, including the ending token.

This example counts tokens. It doesn't run the network.

Try unfamiliar text

Run hello, then 1+1=. Compare what the model writes.

Runs on your device. First load is about 14 MB.

Exact input: "hello"

Model output
No output yet
Input + output
hello

Run to see a prediction.

Model and input details

Printable ASCII is passed verbatim. BOS is added once. All 98 tokens remain available. Context: 32 tokens. Run budget: 16 output tokens, capped by remaining context. EOS ends generation. Unexpected PAD or BOS tokens are visible.

Improved model. Epoch 140. 1.74 MB of weights. The WASM runtime is downloaded on first use.

Optional code

Code and commands for this step

The pieces are examples, token IDs, a network, a loss, weight updates and a generation loop. Running the build commands creates a model from random parameters using this data pipeline.

The browser uses an ONNX file, which packages the trained network for another runtime. Exporting changes how the model is executed. It does not teach it new arithmetic.

Open the complete build sequence to run the project on your machine. Recorded results and file verification are available if you want to compare your run with mine.

Technical details

The 32-token context includes BOS, the input and generated output, including EOS. The tokenizer supports printable ASCII characters only. Longer input is rejected without removing any characters.

Code and training steps