Strip away the magic and there's a single move: guess the next chunk of text, then do it again. Everything a chatbot does is that loop, running very fast.
Give it a few words and it produces a ranked list of what could come next, each with a probability:
"The sky is"
↓
[ model ]
↓
blue 85%
clear 6%
grey 4%
falling 0.1%Made-up numbers, to show the shape — not a reading from a real model.
It picks one — leaning toward the likely ones, with a little randomness so you don't get an identical answer every time — adds it to the end, and feeds the whole thing back in:
"The sky is" → "The sky is blue" → "The sky is blue today" → ...
That's the entire engine. No plan, no meaning, no looking ahead — just the next chunk (a token), over and over, until it stops.
Try it yourself. Hit Predict — it reads the words so far, shows the odds for what comes next, picks one (leaning to the likely ones), and appends it. Then it runs again on the longer sentence:
Show the Python — the whole engine in ~15 lines
A real model computes its probabilities; this toy has them written in by hand:
import random # a toy "model": for this context, what tends to come next model = { "the sky is": {"blue": 0.85, "clear": 0.10, "grey": 0.05}, "the sky is blue": {"today": 0.6, "and": 0.3, ".": 0.1}, } def next_word(context): options = model.get(context.lower()) if not options: return "." words, probs = list(options.keys()), list(options.values()) # pick one, weighted by probability return random.choices(words, weights=probs)[0] text = "The sky is" for _ in range(2): text += " " + next_word(text) print(text)
What a real LLM does differently:
· No lookup table — billions of learned numbers (weights) compute the probabilities instead.
· Its context is the whole conversation, not three words.
· It learned those numbers by reading enormous amounts of text and adjusting until its guesses matched what actually came next. That's training.