Part 5 of 6 · Generation, and the whole roundLearn and do
Each symptom points at a few causes
Each symptom narrows the search to a few causes, and one check usually splits them.
Good loss, wrong text. Where do you look?
| Symptom | Points at | The check that splits it |
|---|---|---|
| Step-0 loss far above lnV | logits too large at init | the trace, from the logits back through the head |
| Step-0 loss well below lnV | the answer reaches the logits before any learning | target check, causality test |
| Random-token loss below lnV | a leak, through attention or the batch | causality test, target check |
| Loss flat from step 0 | no update reaches the weights | overfit one batch, parameter count |
nan or inf | an overflow, a masked row with nothing left to see, a learning rate too high | a hook that reports the first non-finite output |
IndexError from an embedding | an index past the end of the table | print the max of whatever indexes each table |
| Same logits for a repeated token at every position | order never reaches the model | the position test's block 0 hook |
| Good loss, wrong text | code only generate runs, or a leak the loss rewarded | the generation contract, causality test |
| Trains and generates fine | nothing yet: a part can be off in a way this data forgives | a known-good twin |
A bug shows in the curve, only in generation, or nowhere
Sort every bug by the path it lives on, and you can say ahead of time where it shows:
- The training curve shows it, as long as you know what the curve should do: a start far from lnV, a curve that never moves, spikes and
nan, a loss below a floor you know. - Only generation shows it when the bug lives in code that only
generateruns: how it builds the window, how it picks the next token, the cache, the decoding back to text. A leak can belong here too, on text the model can memorize: in generation the next token doesn't exist yet, so at the last position there's nothing to read. - Neither shows it when a part is off in a way the data forgives. On text that a few tokens of context can predict, a weakened part costs too little to see in the curve, and the text still comes out right. Only a test of that part finds it.
In the editor, checks names five checks, and symptoms lists five symptoms from the table. Set first_check: a dict from each symptom to the check that splits it.
Pick an answer above to see the rest
Instructions
- 1
Set
first_check: for each symptom, the check from the table that splits it, as one of the names inchecks.
symptoms.py
Run your code to check it. Output shows here.