PicoGPT-JS

loading…

1 · Corpus & training

Char-level LM, vocab 64. Trains live in your tab — watch cross-entropy fall toward (and below) the Markov baselines.
lr window step 0
Model bits/char (train windows) vs Markov baselines fit on the same corpus — the Shannon question: how much structure beyond order-k statistics does the model capture?
temp

2 · Inspect a sequence

Forward-pass anatomy on one input: attention maps per layer/head and the residual-stream norm along the network.
Residual-stream mean L2 norm per stage

3 · Shannon — entropy & surprisal

Per-position predictive entropy H(p) and surprisal −log2 p(actual next char). Flat high entropy = model unsure; spikes in surprisal = characters the model finds hard.

4 · Markov — model vs n-gram

Per-position surprisal: PicoGPT-JS vs order-1/order-2 Markov chains fit on the corpus. Where the transformer beats the bigram, it is using longer context.

5 · Fisher — curvature of the prediction

Per-token Fisher information H_z = diag(p) − p pᵀ (the categorical curvature at the model's output — the same H_z the Python repo's Hessian analysis factors through). Effective-dimension diagnostics of its spectrum, per position.
Fisher eigenvalue spectrum at the selected position (click a point index) — participation ratio r_PR counts the "effectively active" directions.
position

Information — how to read the results

Tokens: characters, not words

The tokenizer is character-level with a fixed vocabulary of 64 symbols (a–z, digits, punctuation). Every prediction and every generated token is one character; "words" exist only insofar as the model learns them from data.

1 · Loss & bits/char vs Markov

Units. The training loss is the negative log-likelihood of the next character, −log p(target), averaged over positions. Taken with the natural log it is measured in nats (base e); divided by ln 2 the same quantity becomes bits (base 2). So 1 nat ≈ 1.44 bits — the loss chart shows nats, the bits/char chart shows the identical loss converted, which makes it directly comparable to Shannon entropies and the Markov baselines.

An untrained model guesses uniformly: log₂ 64 = 6 bits/char. Markov-1 (bigram) reaches ~2–2.5 bits on English-like text, markov-2 lower. The interesting moment is when the model line crosses below markov-2: from then on the transformer extracts structure no fixed 2-character context can — attention is paying for itself. On the small repeated default corpus a trained model goes far below 1 bit/char: the text is nearly deterministic given enough context (that is memorization — paste a few KB of varied text for an honest gap).

2 · Attention maps & residual norms

Early in training the maps are a uniform lower-triangle smear (causal mask, no learned structure). Trained, heads differentiate: typically one goes near-diagonal (local/previous-character copying) and another develops off-diagonal stripes jumping back to earlier occurrences of the same word — the long-context advantage the Markov panel quantifies. Residual-stream norms growing across stages is normal for pre-norm transformers; the final LayerNorm absorbs the scale.

3 · Shannon — entropy & surprisal

Blue = the model's uncertainty before seeing the next character; red = how surprised it actually was. Inside a memorized word both drop toward 0 (after "th", predicting "e" is easy). Spikes sit at genuine branch points — after a space or period, where several continuations are legal. Red far above blue = confidently wrong. Mean entropy vs the 6-bit maximum gives redundancy; character-level English is highly redundant, so 60–80%+ after training is expected.

4 · Markov — where context depth wins

Bars per position: wherever the model bar is shorter than markov-2 — typically at the start of a repeated phrase — the model is using context deeper than 2 characters. Ties on short common pairs are expected; a bigram is already optimal there.

5 · Fisher — curvature of the prediction

H_z = diag(p) − p pᵀ is the curvature of the loss in prediction space (the same per-token object the Python repo's Hessian analysis factors through). Trace = 1 − Σp²: a confident prediction has curvature ≈ 0, an uncertain one has high trace, and r_PR / erank count how many characters are genuinely still in play — a three-way branch point shows r_PR ≈ 2–3, not 64. It tracks the entropy curve in shape but measures something different: not how unsure the model is, but how many directions of the output distribution the data at that position can still bend. Watch it collapse as training pins predictions down — the per-token seed of effective-dimension analysis.