Skip to content
ginsberg.si

How AI Chatbots Actually Work · Part 1 of 5

How ChatGPT Writes: The Next-Word Engine

How ChatGPT works, in plain English and with no math: text becomes tokens, layers score the next word, and temperature decides how bold the guess is.

11 Nov 2026

An open book spilling word cards into a stack of transformer blocks labeled attention, feed forward, and add and normalize, ending in a next-token list.

How to read this

This series is for a reader who is verbally sophisticated and curious — someone who finishes a long magazine essay, who has read Thinking, Fast and Slow or Sapiens or The Gene — not for someone who already speaks linear algebra as a native language. You do not need a PhD. You do need patience for a careful argument.

A transformer, here, is the architecture behind today's large language models: systems that, given a stretch of text, propose what word (or word-piece) should come next. Everything else — chat, summarization, code assistants — is that engine wrapped in scaffolding.

The companion technical series on this site, Transformers from the Weights Up, covers the same ground in twenty denser lessons. This edition folds those twenty into five longer essays. Where a number earns its keep, we keep it. Where a figure would force jargon without light, we drop it rather than round it into something false.

Map: twenty lessons into five

Nothing important from the original syllabus was discarded — only regrouped for a different voice.

This lessonOriginal lessonsWhat carries over
1. What the machine is doing1, 7, 12Overview; tokens and embeddings; logits, softmax, temperature and sampling
2. How it reads2–5, 8–11Similarity and layers; feed-forward as memory; attention, heads, masking, position; residual stream and normalization
3. How it learns6 (+ training side of embeddings)Loss, gradients, AdamW; weights as stored experience; why scale matters
4. What's in the download14–18Checkpoints; number formats; quantization; Q4_K_M / GPTQ / AWQ; perplexity and KL
5. Running it and peeking inside13, 19, 20KV cache; MoE; long context; FlashAttention; engines; capstone interpretability

Before it is a chatbot, a search engine, or a coding partner, a transformer is a next-word engine: it turns a stretch of text into a ranked list of possible continuations, then picks from that list.

Start with a sentence you might type: "The Eiffel Tower is in the city of." A language model does not look up Paris in a gazetteer. It converts your text into tokens — chunks that are often whole words, sometimes pieces of words — then, through a stack of layers, scores every entry in a huge vocabulary. Those scores become a probability distribution. Sampling yields the next token. Append it, repeat. That loop is the whole show.

Tokenization is the first translation. Models learn a vocabulary of tens or hundreds of thousands of tokens by merging frequent character pairs (byte-pair encoding and its cousins). Each token ID indexes a row in a table of embeddings: a learned list of numbers that places that token as a point in a high-dimensional space. Nearby points tend to behave similarly in context — a dictionary whose entries are locations you can reason with, not prose definitions.

A sentence split into cards, The text invites us to consider language, with one empty glowing card waiting for the next word.

At the far end, an unembedding step turns the final internal state into scores over the vocabulary — logits before they are normalized. Softmax turns scores into probabilities that sum to one. Temperature sharpens or flattens that distribution: lower is more cautious; higher is more adventurous. Other filters (top-k, top-p) further shape the voice.

A ranked list of next words
TheEiffelTowerisinthecityof?
Paris
96.4%
London
2.0%
France
1.1%
the
0.4%
a
0.2%

Illustrative scores, not a live model. Temperature is a boldness knob: lower makes the top choice more dominant; higher spreads the bets.

Why does this feel like understanding? Because predicting the next word, at scale, forces the model to track grammar, facts, style, and argument structure — the same pressures that make a skilled reader anticipate a sentence. It is not a proof of mind. It is a demonstration that next-word prediction is an unexpectedly deep objective.