EP 01 · How AI Actually Works

Strawberry Has 2 R's? How ChatGPT Actually Works Under the Hood (Every Number Measured)

One question traced through Qwen3-4B: tokens, embeddings, attention, the logit lens, sampling, training and a live hallucination.

By Arun Prabhakaran · Originally published 17 Oct 2026 in Towards AI · 11 min full read

TL;DR

ChatGPT-style models predict one token at a time from a flat document rebuilt on every turn, and they never see letters: “ strawberry” is the single token #101830. Measured on Qwen3-4B, words become 2,560-number vectors, attention routes context between them, and the answer “Paris” takes shape by Layer 32 of 36. The model miscounts r's because of tokens, and hallucinates because it is trained for plausibility, not truth.

  • #101830strawberry token
  • 2,560dims per embedding
  • 36layers
  • 92%attention it → animal
  • 31%P(Paris)
Companion video · Strawberry Has 2 R's? How ChatGPT Actually Works

Summary

This article follows one question, “Which city is the Eiffel Tower in?”, through Qwen3-4B, an open-weight model built on the same transformer recipe as ChatGPT, with probes on every layer. It opens with a puzzle: with Thinking switched off, the model says “strawberry” has 2 r's; with Thinking on, it says 3.

The explanation starts before the network runs. The chat app rebuilds the whole conversation as one flat document on every turn, so the model has no memory of you; the history is the memory. A tokenizer then turns text into integer IDs. In OpenAI's o200k_base vocabulary, “ strawberry” is the single token #101830 (#72600 in Qwen3), so its letters are never visible. The same question costs 6 tokens in English and 11 in Hindi.

Each token becomes a 2,560-number embedding in which Paris sits near France and 巴黎. Self-attention lets words borrow context: one head looking from “it” puts 92% of its weight on “animal”. Through a logit lens, “Paris” only takes first place at Layer 32 of 36, after the base model spends Layers 24–28 predicting a fill-in-the-blank underline. Its final distribution gives “ Paris” 31%, and temperature decides how that weighted die is rolled.

The article also walks through the three training stages (pre-training, SFT and RLHF; Llama 3 used 15.6 trillion tokens, about 250,000 years of human reading) and a live hallucination: asked about an invented “Kesharpur Tower”, the model confidently placed it in Bihar. Thinking mode fixes strawberry because spelling the word out turns each letter into its own token that attention can count.

This page is a short summary written for this site. Every figure, table, code sample and reference is in the original article on Towards AI.

Questions this article answers

Why can't ChatGPT count the r's in strawberry?

Because the model never sees letters. A tokenizer turns text into integer IDs before the network runs, and in OpenAI's o200k_base vocabulary “ strawberry” is the single token #101830 (#72600 in Qwen3). With Thinking off, Qwen3-4B answered 2. When it was allowed to spell the word out in a scratchpad, each letter became its own token, the attention heads could count them, and it answered 3.

Does ChatGPT remember my previous messages?

Not inside the network. The model is stateless: on every turn the app rebuilds one flat document containing hidden system instructions, the earlier turns of your chat, your new question and a marker saying it is the assistant's turn. The model only predicts the next piece of text for that document, then repeats the loop. The conversation history is the memory, and the weights do not change while you chat.

Why does clicking Regenerate give a different answer?

At the top of the network the model outputs a score for every token in its roughly 151,936-entry vocabulary, and softmax turns those scores into probabilities. For “The Eiffel Tower is in the city of”, Qwen3-4B-Base gave “ Paris” 31%. A sampler then rolls a weighted die shaped by temperature: near 0 it always takes the top token, around 0.7 it varies naturally, and above 2.0 it drifts into gibberish.

Why does ChatGPT make things up (hallucinate)?

An LLM has no database to look facts up in, only weights trained to produce plausible continuations. Asked which city the Kesharpur Tower is in, a tower that does not exist, Qwen3-4B said it was in Bihar. The article points to three causes: training rewards confident-sounding text, benchmark grading gives a guess more expected points than “I don't know”, and once wrong tokens are written, later tokens build on them.

How is ChatGPT trained?

In three stages. Pre-training teaches next-token prediction on huge amounts of text; Meta's Llama 3 used 15.6 trillion tokens on up to 16,000 H100 GPUs, roughly 250,000 years of reading at 8 hours a day. Supervised fine-tuning then teaches the user and assistant turn format from example conversations. Finally, RLHF trains a reward model on human rankings of answers and optimises the LLM toward the responses people prefer.

More in How AI Actually Works