How ChatGPT Generates Answers
Parts 4 through 6 covered the general mechanism behind generative language models. This part traces that exact mechanism through one real, specific, widely used product — ChatGPT — end to end, from a typed question to a displayed answer.
Step 1: your real, typed question becomes tokens
You type: "Why does coffee go stale?"
Real tokenization (covered fully in part 8) breaks this into smaller
pieces the model actually operates on — not necessarily whole
words, and not visible to you as a user at allEverything you type is converted into real, numerical tokens before the underlying model ever sees it — this conversion is invisible in the ChatGPT interface, but it's the real, actual input format the model works with, not raw text.
Step 2: real conversation formatting
The real, complete input the model actually receives isn't just
your question — it includes:
- A real system prompt (part 11) shaping the assistant's behavior,
set by OpenAI, not visible to you in the standard interface
- The real conversation history, if this isn't the first message
- Your actual new questionThis is a real, important detail often missed: what the underlying model receives is genuinely more than the single question you typed — it's a real, structured sequence including a hidden system prompt and the full conversation so far, formatted in a specific real way the model was trained to expect (covered precisely in part 11).
Step 3: the real model generates a response, one token at a time
This is exactly part 4's autoregressive process, applied here
concretely:
"Coffee" → "Coffee goes" → "Coffee goes stale" → "Coffee goes
stale mainly" → ...continuing one real token at a time, until the
model generates a real, special "stop" token signaling it's doneEach real token is generated based on everything before it — your question, the conversation history, and every token the model has generated so far in its own current answer. This is genuinely why longer ChatGPT answers can feel like they're "building on themselves" — because they literally are, one real prediction step at a time.
Step 4: real, live streaming to your screen
Rather than waiting for the ENTIRE real answer to finish generating,
ChatGPT's interface displays each token as soon as it's produced —
the real, visible "typing" effectThis streaming behavior (covered as a real, practical implementation detail in part 17) is a genuine, deliberate user-experience choice, not a technical requirement — the model could generate a complete answer before displaying any of it, but showing tokens as they're produced gives real, immediate feedback that something is happening, rather than a real, silent wait.
Nothing in this real, four-step process involves the model looking anything up in real time, unless a specific tool (like real-time web search) is explicitly invoked — the entire response is generated purely from the model's trained patterns plus whatever's actually included in the real conversation context. This is the same real limitation from part 5's training-cutoff coverage, made concrete: if a question needs current, real information beyond the model's training data and conversation context, the raw generation process alone genuinely can't provide it.
Why the same real question can produce different real answers
This directly restates part 4's sampling behavior, concretely: at
each real generation step, the model doesn't always pick the
single most likely next token — it samples from among several
real, plausible candidatesThis is exactly why asking ChatGPT the same real question twice, even in separate conversations, can produce two genuinely different (but both reasonable) phrasings or structures — a deliberate, real design choice for more natural-feeling variation, not inconsistent or unreliable behavior.
The real, complete picture, assembled
Your question → tokenized → combined with system prompt and history
→ fed through the trained model → tokens generated one at a time,
sampled from likely candidates → streamed to your screen as
they're producedThis exact real pipeline — tokenization, context assembly, generation, streaming — is precisely what the coding project starting in part 16 builds directly, using a real API instead of ChatGPT's own consumer interface. Nothing covered in this part is unique to ChatGPT specifically; it's the real, general mechanism behind any product built on a large language model.
Next: what tokens actually are — the real, precise unit every step of this process actually operates on, covered in full detail.