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 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.
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 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.
More Technology questions
- Why can a satellite redness index flag rusting Arctic rivers but still fail to tell which streams are chemically hazardous?
- 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 Cloudflare's lava-lamp camera feed improve encryption even though the cryptographic software that consumes it is deterministic?
- If an attacker learns a pseudorandom generator's seed and algorithm after watching several outputs, why can the later outputs become reconstructable?
- If a phone game shuffle and a physical noise source both look messy, what makes only one useful for security against someone who knows the code?
- At parking-lot speed, why do quiet EVs need alert sounds before tire noise helps?