What is a token? (It’s not a word)
Here’s a secret that explains half of the weird behavior you’ve ever seen from an AI: language models can’t see letters. They can’t see words either. They see tokens — chunks of text, chopped up by a fixed set of scissors called a tokenizer.
Don’t take my word for it. Type your name and watch:
💡 Each colored block is one token. The number underneath is its ID — the ONLY thing the model receives. Not letters. Not sounds. Just this number.
Common words like the or hello get one block. Your surname probably got chopped into two or three. Why? Time for the actual mechanism — it’s simpler than you’d expect, and once you see it, tokenizers stop being magic.
How the scissors were made: the compression game
Imagine you had to compress all the text on the internet, and you’re only allowed a dictionary of ~100,000 entries. Here’s the algorithm that builds it, and you could run it by hand:
- Start stupid: your dictionary is just the individual characters.
hello=h+e+l+l+o, five tokens. - Scan a mountain of text. Find the pair of neighboring tokens that appears most often. Maybe it’s
t+h. - Glue them:
this now one dictionary entry. Everywhere in the text, replacet+hwithth. - Repeat. Next most common pair? Maybe
th+e→the. Thenin+g→ing. Then␣+the→␣the. - Stop after ~100,000 merges. That’s your tokenizer. Forever. Frozen.
This is called Byte Pair Encoding (BPE), and it explains everything you’ll see below. Frequent text got merged into big comfortable chunks. Rare text never earned a merge and gets assembled from fragments, like IKEA furniture. The tokenizer is literally a fossil record of what text was common on the internet at training time.
Watch the fossil record in action — one real English word next to one word the internet rarely writes:
💡 'understanding' was common enough to earn merges. Bush's 'misunderestimating' wasn't — count the fragments.
Four consequences (each one is a famous AI ‘bug’)
1. The strawberry problem. You’ve seen the internet laughing at models that can’t count the r’s in “strawberry.” Now you can see why:
💡 The model doesn't see s-t-r-a-w-b-e-r-r-y. It sees maybe [str][aw][berry]. Counting letters inside a token is like counting eggs inside a baked cake.
The model was never shown letters. Asking it to count them — or spell a word backwards, try that on any model — is asking it to reason about something it cannot perceive. When it gets it right anyway, that’s memorization, not looking.
2. The math problem. Type a big number:
💡 Small numbers are one token each. Big numbers get chopped at arbitrary places — 7739 might be [77][39]. Try shifting digits and watch the cut points move.
Imagine doing addition where the numbers are randomly pre-chopped into chunks and you’re only shown the chunk IDs. That’s why language models are famously shaky at arithmetic: the tokenizer sabotages the digits before the model ever sees them. (Modern models are trained hard to compensate — but now you know what they’re compensating for.)
3. The invisible space. Look closely at any block: the token isn’t hello, it’s ␣hello — the space is glued on. To the model, hello at the start of a sentence and hello mid-sentence are two entirely different tokens with different IDs:
💡 Two 'identical' words. Compare the IDs. A stray trailing space in your prompt genuinely changes what the model sees.
4. The German tax. English got the good seats in the compression game, because most internet text is English. Every merge spent on ␣the was a merge not spent on German:
💡 Same meaning. Count the difference — and remember it, because next lesson this becomes actual money.
The cursed tokens (a true story)
In 2023, researchers poking through GPT’s dictionary found tokens that should never have existed — and asking the model about them made it malfunction on camera: refusing, insulting the user, or answering about a completely different word.
The most famous was SolidGoldMagikarp. It was the username of a Reddit power-user from a forum where people literally just count upwards (r/counting). Their name appeared in the scraped text so many times that the compression game gave it its own token — but the text itself was then filtered out before the model trained. Result: a token the model saw the ID of, but almost never saw used. A word-shaped hole in its brain. When users typed it, the model fell into the hole.
These “glitch tokens” have mostly been cleaned up in modern tokenizers, but the lesson stands: the dictionary is frozen at training time, full of fossils, and the model inherits every quirk of it. Somewhere in every model’s vocabulary, a Reddit counter is immortal.
So what does the model DO with token IDs?
One-sentence teaser for later modules: each ID is a row number in a giant table, and each row holds a list of a few thousand numbers describing that token’s meaning — its coordinates in “meaning space,” where king sits near queen and Paris near France. Everything the model does happens to those coordinates. But that’s Module 4. For now: text → chunks → IDs. That’s the whole input.
Exercise: Token safari 🏆
Three trophies to hunt. The counter is your judge:
- The Heavyweight: one single English word that costs 5+ tokens (chemical names, fake brand names, and
supercalifragilisticexpialidociousare good hunting grounds) - The Featherweight: a string of 20+ characters costing ≤ 2 tokens (think: what does the internet repeat constantly?)
- The Shapeshifter: a word whose token count changes when you capitalize it (
hellovsHELLOvsHeLLo— why would SHOUTING be rarer in the training text?)
- ☐1 word ≥ 5 tokens
- ☐≥20 characters and ≤2 tokens
- •Find a word where capitalization changes the count
How was the tokenizer's dictionary built?