← All Demos

The Next Token

The model is always just predicting the next token. Temperature and top-p decide how it picks.

robert@barcik.training

Prompt:
The text so far (the prompt is bold, every box is one sampled token with the probability it had)

What could come next?

The model gives every candidate a score. The scores become probabilities, and one token is drawn.

Run it 10 times

Same prompt, same settings, ten complete sentences. How many different ones do you get?

The two knobs

1.0
0 · always the top token2 · almost anything goes
1.00
0.1 · only the surest1 · keep every candidate

Space or → samples the next token. You can also click a bar to choose a token yourself.

What the knobs do

Temperature divides every score before the scores are turned into probabilities. Below 1 the favourite gets even stronger; above 1 the differences flatten and unlikely tokens get a real chance.

p(token) = exp(score / T) / Σ exp(score / T)

Top-p sorts the candidates by probability, keeps the smallest group whose probabilities add up to at least p, and throws the rest away before drawing.

Neither knob makes the model know more. They only change how boldly it picks from what it already predicted.

What is real here and what is not: the scores behind each bar are hand-written for a few candidates per step, so the sentences are a small scripted world. A real model scores every token in its vocabulary (on the order of 100,000) at every step. The calculation applied to the scores, the softmax with temperature and the top-p cut, is the standard one.

AI transparency

This demo is a scripted, self-contained browser simulation. Nothing you type is sent to an AI model and no live AI system runs behind it, even where it plays one. Its code and copy were built with generative AI (Anthropic’s Claude) and reviewed by Robert Barcik, who is responsible for what is published (LearningDoe s.r.o.). Disclosed in the spirit of Article 50 of the EU AI Act.