Why can adding one leading space change a word's token ID in a GPT-style tokenizer?
Show answer & explanation
Answer: The space becomes part of the token.
The model reads it by syllables. — Syllables are a human speech pattern, not the usual unit for GPT-style tokenizers. Tokenizers are trained on text statistics, so they merge common written chunks rather than spoken beats. That's why a silent leading space can affect token IDs even though it adds no syllable.
The word gets shorter. — The word doesn't actually get shorter; the tokenizer just splits the text differently. A leading space can be grouped with the following letters as one piece, which might even change the number of tokens. The key is that token length isn't the same as character length.
The space becomes part of the token. ✓ — In GPT-style tokenizers, the tokenizer learns common chunks of text, and these chunks often include spaces. So 'red' and ' red' are different sequences of characters, and the tokenizer may assign them different token IDs. This is why adding a space can change the token ID.
More Technology questions
- Why can a satellite redness index flag rusting Arctic rivers but not identify chemically hazardous streams?
- A service publishes a fresh random number every minute, plus a public log in which each entry carries a fingerprint of the entry before it. What does that chaining add?
- Why can a wall of lava lamps used as a camera feed improve encryption even though the cryptographic software that consumes it is deterministic?
- Why can an attacker who learns a pseudorandom generator's seed and algorithm reconstruct later outputs?
- Why is a physical noise source secure against an attacker who knows the code, unlike a phone game shuffle?
- Why do quiet EVs need alert sounds at parking-lot speeds before tire noise becomes audible?