GGiriBioAI

/ module 02 · Foundations

Tokens

Models don't read characters, instead they read tokens. A tokenizer splits your text into chunks and maps each chunk to an integer ID. The choice of tokenizer changes everything downstream: vocabulary size, sequence length, even bias.

By the end you can
  • Explain what a token is and why models need them
  • Compare character, word and subword (BPE) tokenizers
  • Predict why emoji, code and other languages cost more tokens

Try this first: Switch to GPT-4o mode and type your name in two languages.

about 10 min hover ? for help

concept

Why tokens?

Neural networks operate on numbers. Tokenization is the bridge from text to integer IDs the model can embed and process. The most common modern approach is Byte-Pair Encoding (BPE), which learns frequent subword chunks like tion, ing, or the.

Trade-offs: character-level tokenizers have tiny vocabularies but long sequences. Word-level tokenizers have huge vocabularies and can't handle new words. BPE sits in the middle. The three teaching modes are simplified; the GPT modes run the exact tokenizers OpenAI models use, right in your browser.

token
A chunk of text mapped to an integer ID.
context window
Max number of tokens a model can read at once.
BPE
Byte-Pair Encoding, which learns frequent subwords.
Live lab · Tokenizer
teaching:
real:
19 tokens · 8 words · 40 chars
The·quick·brown·fox·is·learning·to·read.
"The"#1084
" "#1032
"qui"#1113
"ck"#1099
" "#1032
"bro"#1098
"wn"#1119
" "#1032
"fox"#1102
" is"#1032
" "#1032
"lea"#1108
"rn"#1114
"ing"#1105
" to"#1032
" "#1032

IDs in teaching modes are made up. Pick a GPT mode for true IDs.

Bigger, newer vocabularies usually need fewer tokens for the same text, especially for code and non-English languages, which makes those models cheaper and lets more fit in the context.

Check yourself

Tick each one you could explain to a friend. If you can't yet, scroll back up and replay the lab.

Finished exploring?
Progress is saved only in this browser.