Next-token sampler

A language model predicts the next token from the ones before it. This tiny model counts word sequences in the text you paste, then samples a continuation from those counts; the temperature and top-k knobs are the same ones you meet in real tools. Everything runs in this page: nothing you type, paste, or generate leaves your browser.

Text
Model

Higher orders copy longer stretches of the text; with a short sample most contexts have only one continuation, so temperature and top-k have less to act on. Start at order 1 to see the knobs, then raise the order to see copying.

Press Generate to sample a continuation.

What to notice: a low temperature with a short context tends to repeat phrases straight out of the source text; a high temperature with top-k off wanders into word salad; top-k 1 always takes the single most likely word, so the result no longer depends on the seed.