Our example sentence Watch
Someone types: "yesterday me and my friend goes to market for buy vegetable." and asks the AI to fix it. We spot the mistakes at once. The AI does not see words like we do - it sees numbers. Let us follow the journey.
Correct this sentence and list every change you made:
yesterday me and my friend goes to market for buy vegetable.
Step 1: The sentence is cut into tokens Watch
First a program called the tokenizer cuts the text into small pieces called tokens. A token can be a whole word, part of a word, a space plus a word, or a full stop. Our sentence becomes 13 tokens.
- One word can be two tokens: "yesterday" in small letters at the start is cut into "y" + "esterday".
- The space belongs to the token: " friend" (with the space in front) is one token.
- Capitals matter: "Yesterday" with a capital Y is a single, different token.
Step 2: Every token gets an ID number Watch
Next, the tokenizer looks up each token in its vocabulary: a fixed list of every token the model knows, each with its own number, called the token ID. These are the real IDs from the tokenizer OpenAI uses for GPT-4o, which knows about 200,000 tokens:
| Token | ID number | What it shows |
|---|---|---|
| "y" + "esterday" | 88 and 15198 | small y at the start: split into two tokens |
| "Yesterday" | 70877 | capital Y: one token, a different number |
| " friend" (with a space) | 5168 | the space is part of the token |
| "friend" (no space) | 18924 | without the space it is another token |
| " to" | 316 | the same token always gets the same number |
| " vegetable" and " vegetables" | 50593 and 30400 | singular and plural are separate tokens |
So the AI never receives your words. It receives a row of numbers: 88, 15198, 668, 326, 922, 5168 ... and from here on it works only with numbers.
Where do the ID numbers come from? Watch
The numbers are not random, and nobody types them by hand. They are made once, before the AI model is trained, when the tokenizer itself is built. The usual method is called Byte Pair Encoding (BPE), a 1994 data-compression trick that was adapted for AI language models in 2016.
- Collect a huge amount of text: books, websites and code, in many languages.
- Start with single characters: the first 256 numbers go to single characters (bytes). That is why "y" is 88 and the full stop is 13.
- Count the pairs: find the two pieces that sit next to each other most often in all that text, such as "t" and "h".
- Merge and number: join that pair into one new token and give it the next free number.
- Repeat: do this again and again, until the list is full: about 50,000 tokens for GPT-2, 100,000 for GPT-4 and 200,000 for GPT-4o.
After that the vocabulary is frozen. The same text always gives the same numbers, which is why " to" is 316 every single time.
What the ID number means, and what it does not Watch
- It is only a label: like a roll number in class. Token 70877 is not bigger, better or more important than token 13.
- Small numbers were made early: single characters and very common pieces, like " the" (290). Rarer pieces were merged later, so they got bigger numbers.
- Every model family has its own list: " friend" is 1545 in GPT-2, 4333 in GPT-4 and 5168 in GPT-4o.
- Hindi needs more tokens in older lists: the short sentence "कल मैं बाज़ार गया।" takes 27 tokens in GPT-2, 21 in GPT-4 and only 7 in GPT-4o, which has many more Hindi pieces. Fewer tokens means faster and cheaper answers.
Step 3: ID numbers become meaning Watch
An ID number alone carries no meaning, so the model uses it as a row number in a giant table called the embedding table: one row for every token, and each row is a long list of numbers (GPT-3 used 12,288 numbers per token). ID 5168 simply means "take row 5168".
Those rows were learned during training, so tokens with similar meanings ended up with similar rows: " went" sits close to " goes" and " go", and " vegetables" close to " vegetable" and " fruits". That is how the AI knows that goes and went are the same action at different times.
Step 4: Attention finds the mistakes Watch
Now every token looks at every other token and asks: which of you matter to me? This is called attention, and it runs through dozens of layers.
- Tense: "goes" pays strong attention to "yesterday", which means the past, so it should be "went".
- Pronoun: "me and my friend" is the subject, so it should be "my friend and I".
- Missing word: we say "to the market".
- Purpose: "for buy" should be "to buy".
- Plural: after "buy", "vegetable" usually means many, so "vegetables". Plus a capital Y and a comma.
Nobody typed these grammar rules into the model. It learned the patterns by reading billions of correct sentences during training.
Step 5: The corrected sentence is written one token at a time Watch
The AI now writes its answer. At every step it gives each of its 200,000 possible tokens a score and turns the scores into probabilities. After "Yesterday, my friend and I", a likely result is: " went" 91 percent, " go" 4 percent, " goes" 2 percent (example numbers). " went" wins, is added to the answer, and the whole process repeats for the next token.
Token by token the new sentence appears: "Yesterday, my friend and I went to the market to buy vegetables." - 14 tokens, turned back into words by the same vocabulary list. Many apps then show the old and new sentence side by side, with every change highlighted.
Does the AI remember my sentence? Watch
While it works, your sentence sits in its short-term memory, the context window. When the answer is done, those temporary numbers are thrown away, and the model does not learn from your sentence on the spot. The app may save your chat history, depending on its settings - that is separate.
Lesson learned Watch
AI never reads your words: it cuts them into tokens, swaps each for an ID number from a fixed list built by merging common pairs, looks up its meaning, finds the mistakes with attention, and writes the fix one token at a time.
Frequently asked questions
What is a token ID?
The number a tokenizer gives each token: its position in the model's fixed vocabulary list. It is a label, not a value, and the model uses it to look up the token's meaning vector.
Who decides the ID numbers?
Nobody picks them by hand. They are created once when the tokenizer is built, usually by Byte Pair Encoding: single characters first, then the most common pairs merged and numbered in order.
Why does the same word have different IDs in ChatGPT and Gemini?
Each model family builds its own vocabulary from its own text, so the lists and the numbers differ.
Why does Hindi use more tokens?
Older vocabularies were built mostly from English text, so Hindi words were cut into many small pieces. Newer vocabularies, like GPT-4o's, include many more Hindi pieces.