Next-word playground

A GPT-style model does one thing: given the text so far, it gives every word in its vocabulary a probability of coming next. Writing is that step repeated. Type the start of an English sentence and see what our tiny model expects.

Start of an English sentence
The model reads at most 31 words and marks.

The 10 most likely next words

Anna has a small …

  1. flower 13.3 %
  2. cat 12.8 %
  3. horse 11.1 %
  4. bird 10.8 %
  5. car 9.7 %
  6. house 9.5 %
  7. dog 9.3 %
  8. door 8.7 %
  9. ball 8.0 %
  10. lamp 6.8 %

After temperature 1.0 and top-k 10. At temperature 1 with every word, the model gives its top word 13.1 %.

Temperature and top-k

The model's last layer gives each word a score; the softmax turns scores into probabilities. Temperature divides the scores first: below 1 the differences grow and the top word takes more of the probability, above 1 they shrink and unlikely words get a chance. Top-k keeps only the k most likely words and shares the probability among them. These are the same two settings an LLM API offers, doing exactly this.

Greedy writing always takes the top word, so it is repeatable and safe, and can be dull. Sampling draws a word at random with those probabilities, so the same start can continue differently; fixing the seed makes the draw repeatable.

Our model knows only the simple English of its corpus and was trained in minutes, so it predicts well inside that world and nowhere else. It is built as GPT-2 is (decoder only, normalisation before each sub-layer, learned positions, GELU), at about a thousandth of the size of the smallest GPT-2.

An unhandled error has occurred. Reload 🗙

Reconnecting…

Your connection to the Transformers and Attention Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.