Loading slide

Tokens

  1. 01Tokens
  2. 02Memory card
  3. 03The model can't read
  4. 04Not words. Tokens.
  5. 05The emoji trick
  6. 06Try it yourself
  7. 07How many r's in strawberry?
  8. 08What the model actually sees
  9. 09Some languages cost more
  10. 10Why "cat" and " cat" differ
  11. 11Why not millions of tokens?
  12. 12So why not just use bytes?
  13. 13Context windows are measured in tokens
  14. 14Reinforce your understanding
  15. 15Question: Why not just use words?
  16. 16Question: Weird splits
  17. 17Quiz: answer
  18. 18What to carry out of this chapter
  19. 19Want to go deeper?
8 / 18
BackNext

What the model actually sees

When you type a message to a language model, you see words and sentences. The model sees a row of numbers, one per token.

Each token in the vocabulary has an ID number. In one common tokenizer, "The" is 464, " cat" is 2415, and " sat" is 3332. So the sentence "The cat sat" reaches the model as three numbers: 464, 2415, 3332. That row of numbers is the whole input. The model never gets the letters back.

This simple fact has consequences that catch people out. We just met one: because the model only ever sees whole tokens, never the letters sealed inside them, it can fumble a question as easy as how many r's are in "strawberry."

The next two slides show two more, and both matter in everyday use: why the same sentence can cost very different amounts in different languages, and why "cat" and " cat" are two separate tokens at all.

Citations(2)↓
  1. 1. huggingface.co
  2. 2. arxiv.org