A typo still breaks into pieces the model has already learned
Subword tokenizers split a misspelling into fragments that already carried meaning from training, and the same flexibility gives a deliberate attacker a way in.
Why this matters
Every chatbot conversation is full of them: a dropped letter, two letters swapped, a word typed the way it sounds instead of the way it's spelled. The reply comes back as if none of it happened. That's stranger than it looks, because nothing in a language model corrects your spelling before reading it: no spell-checker under your prompt, no dictionary lookup, no stage built to notice a word is wrong. By the end of this lesson you'll know what happens instead: a fixed, frequency-learned way of cutting text into pieces, and where that same flexibility stops being a safety net and starts being something an attacker can use.
- 01
- The token a model can't repeat back: the inverse failure, a token that reached the vocabulary but never reached the model's training.
- 02
- A transformer redraws a word's vector for every sentence it appears in: the vector mechanism this lesson leans on for why a token's pieces already mean something.
Nothing in the pipeline checks your spelling
A message that reads "i dont no if this is neccessary" gets answered by a chatbot as though every word in it were spelled correctly. The easy explanation is that something quietly fixes the spelling before the model sees it, the way a word processor underlines a typo and offers the right one. That explanation is wrong, and no source says so directly. A complete description of the pipeline simply leaves the correction step out.
The paper that introduced the transformer architecture behind GPT models lays out every stage between raw tokens and a predicted next word. Each token is embedded, gains a signal for its position, passes through repeated blocks of self-attention and feed-forward transformation, and is projected through one linear layer and a softmax into a probability over the entire vocabulary.1 Turning text into tokens, the step before any of that, is described in OpenAI's GPT-2 paper as a fixed merging procedure applied to raw bytes. The paper treats avoiding "lossy pre-processing" as a stated design goal, not a step it adds.2 There is no spelling stage: the pipeline has tokenizing, embedding, attention, and next-token prediction, and nothing else.
A misspelling breaks into more, smaller tokens
Before any of those stages run, the raw text is cut into tokens: chunks that can be a whole common word or as short as a single character, chosen by an algorithm called byte-pair encoding, or BPE. BPE began as a text-compression algorithm and was later adapted for exactly this kind of tokenization.3 It learns its chunks once, from a large body of training text, before the model itself ever trains. It counts every pair of adjacent symbols in that text, merges the single most frequent pair into a new symbol, and repeats the merge a fixed number of times.4 Whatever symbols survive become the fixed vocabulary. New text is split into characters, then rebuilt by replaying those merges into the largest known chunks.4 A rare or misspelled word that never appeared whole in training simply comes out as more, smaller pieces instead of one piece.4
GPT-2 and its successors run that merging procedure over raw bytes rather than characters, so the starting alphabet is only 256 symbols instead of the 130,000-plus Unicode would need.2 Any string can always be represented; the worst case is a word breaking all the way down to individual bytes.2
A live run of tiktoken, OpenAI's own tokenizer, using the
cl100k_base vocabulary that backs GPT-3.5-turbo and
GPT-4,5 shows exactly
this split. "Necessary" comes out as a single token. "Neccessary"
comes out as three: "ne", "ccess", and "ary".6
The same pattern holds across other ordinary misspellings:
| Word | Tokens | Pieces |
|---|---|---|
| necessary | 1 | necessary |
| neccessary | 3 | ne · ccess · ary |
| beautiful | 1 | beautiful |
| beautifull | 4 | be · aut · if · ull |
| definitely | 2 | def · initely |
| definately | 3 | def · in · ately |
The fallback goes all the way to raw bytes when nothing else matches: an emoji not covered by any learned merge splits into the UTF-8 bytes that encode it, three tokens for one emoji, nothing dropped.6 A tokenizer built this way never has an unrecognized word to substitute or correct, only bytes to fall back on.
That same subword mechanism runs the opposite way when the vocabulary itself misfires. The token a model can't repeat back describes strings that earned their own token during tokenizer training but almost never appeared during the model's training, so that token's meaning never formed. That is the inverse of a typo: one whole token with no learned meaning, instead of a misspelled word broken into pieces that already mean something.
Common pieces already carry the meaning
Once split into tokens, each piece enters the model as a vector: a long list of numbers learned during training. A transformer redraws that vector for the sentence a token is actually sitting in, but the vector it starts from already reflects everywhere that token showed up in training, whatever word it was part of.
Nothing in that pipeline defends against typos on purpose, either. Researchers building subword translation systems have said as much about their own work: rather than building in a defense, "we instead hope that the relevant noise will occur in the training data."7 Whatever tolerance for a misspelling exists has to come from what byte-pair encoding already does to ordinary text, not from a designed correction step.
That points to the real reason the pieces still mean something. BPE's merge rule only ever promotes the single most frequent symbol pair in the training text, repeated until its merge budget runs out.4 A fragment small enough to survive on its own is, by construction, one of the more common sequences in the language. "Ne", "ccess", and "ary" turn up constantly across ordinary, correctly spelled words. Each has had far more chances to earn a well-trained vector than the rare string "neccessary" ever would alone. A misspelling breaking into recognizable pieces is not the model recalling this exact typo. It is the tokenizer handing the model pieces it already understands, arranged in an order it hasn't seen but can still read from what those pieces mean elsewhere.
Context makes the intended word the most likely next one
The last stage in the pipeline turns every token's vector into a probability distribution over what comes next.1 A model reading "...that isn't neccessary for the meeting" has already turned "ne", "ccess", and "ary" into vectors near "necessary". Every other token in the sentence is available too. An attention head is a weighted average that computes its own weights across exactly those earlier tokens, so the surrounding words vote on what the misspelled one most likely means, the same way they would for the correctly spelled version.
The model then predicts one token, appends it, and runs again, reasoning from that point about a sentence with "ne", "ccess", "ary" sitting where "necessary" would have. None of this rewrites those tokens into "necessary"; they stay exactly what the tokenizer produced. What changes is which continuation those pieces, read in context, make most probable.
The same flexibility that helps a typo also helps an attack
Put together, this is settled: fixed, frequency-learned pieces, already meaningful from training, read in context by a mechanism never built to notice a misspelling.124 It is not a guarantee against every character-level change, though, and the line between an everyday typo and an adversarial input is fuzzier than a clean split.
A 2023 benchmark ran algorithm-searched, maximum-damage character edits against nine large language models, including GPT-3.5 and GPT-4, and found an average 20 percent drop in task performance. GPT-4 was among the most robust models tested, but not immune.8 The authors describe those same edits as "plausible user errors like typos,"8 blurring the line between an everyday typo and a crafted one. A 2025 study of GPT-4o and a large Llama model found something related: the model's own wording measurably changes between a clean prompt and one perturbed with synthetic, keyboard-adjacent typos.9 That is not evidence of a misread. The study measures wording overlap, not comprehension, so a changed answer can still be a correct one stated differently.9
The same study complicates the training-data story further: it describes large language model training sets as "curated datasets that lack human-induced errors, such as typos."9 That favors the reading this lesson has argued for, where "ne", "ccess", and "ary" are common pieces on their own, over the folk version where the model simply memorized this one typo.
The same subword flexibility that lets an accidental typo land safely gives a deliberate attacker more precise room to work. Testing a fine-tuned BERT sentiment classifier, researchers found that a single character added, dropped, or swapped, chosen to do maximum damage, dropped its accuracy from 90.3 percent to 45.8 percent.10 Subword and character-level models turned out more vulnerable to this than word-level models, because every character edit produces a genuinely different sequence for an attacker to search over.10
A further class of attack sits outside typo robustness altogether. Homoglyphs, a Cyrillic "а" standing in for a Latin "a", and invisible Unicode characters change what bytes a tokenizer receives without changing what a human reader sees.11 A single substitution can measurably degrade a target system. Three can functionally break many of the machine-translation, moderation, and classification systems tested.11 A typo is visible to everyone who reads it. An imperceptible encoding attack, by design, is not, and it targets the boundary between text and bytes directly rather than producing a spelling variant anyone would notice.
- Character-level edits searched for maximum damage still cut performance on GPT-4-class models by roughly a fifth on average.8
- One deliberately chosen character edit collapsed a classifier's accuracy from 90.3% to 45.8%.10
- Homoglyphs and invisible characters are invisible to a human reader and can functionally break a target system with as few as three injections.11
An explanation that only says the model "understood" a typo does not distinguish an ordinary misspelling from a Cyrillic "а" standing in for a Latin one, and that distinction is exactly what separates a solved problem from an open one.
The takeaway
A typo works because tokenization, not correction, does the reading. Byte-pair encoding cuts any string, misspelled or not, into pieces from a fixed vocabulary built by merging the most frequent chunks in training text. A piece too rare to survive on its own still breaks into smaller pieces common enough to already carry a well-trained meaning. Context finishes the job: attention over the rest of the sentence makes the intended reading the most likely next prediction. That is settled engineering, not a lucky accident. It is also not a guarantee: character-level edits built to do damage still measurably hurt GPT-4-class models, and homoglyphs exploit the same tokenizer from an angle no accidental typo reaches. The next time an explanation says only that a chatbot "understood" a typo, this lesson supplies the missing step: which tokens it actually read, and why those tokens already meant something.
- 01
- Boucher, Shumailov, Anderson, Papernot, "Bad Characters: Imperceptible NLP Attacks": the full catalog of homoglyph and invisible-character attacks this lesson's edge case only samples.
- 02
- Zhu et al., "PromptRobust: Towards Evaluating the Robustness of Large Language Models on Adversarial Prompts": the full benchmark behind this lesson's character-level robustness numbers, run across nine models.
Sources
- arXiv · Vaswani, Shazeer, Parmar, Uszkoreit, Jones, Gomez, Kaiser, Polosukhin, "Attention Is All You Need" (NeurIPS 2017)
- OpenAI · Radford, Wu, Child, Luan, Amodei, Sutskever, "Language Models are Unsupervised Multitask Learners" (GPT-2, 2019)
- Hugging Face · "Byte-Pair Encoding tokenization," LLM Course
- ACL Anthology · Sennrich, Haddow, Birch, "Neural Machine Translation of Rare Words with Subword Units" (ACL 2016)
- OpenAI Cookbook · "How to count tokens with tiktoken"
-
GitHub · OpenAI, tiktoken v0.14.0, live run against
cl100k_base(2026-09-18) - arXiv · Belinkov, Bisk, "Synthetic and Natural Noise Both Break Neural Machine Translation" (ICLR 2018)
- arXiv · Zhu, Wang, Zhou, Wang, Chen, Wang, Yang, Ye, Gong, Zhang, Xie, "PromptRobust: Towards Evaluating the Robustness of Large Language Models on Adversarial Prompts" (2023)
- Scientific Reports · Alahmari, "Large language models robustness against perturbation" (2025)
- ACL Anthology · Pruthi, Dhingra, Lipton, "Combating Adversarial Misspellings with Robust Word Recognition" (ACL 2019)
- arXiv · Boucher, Shumailov, Anderson, Papernot, "Bad Characters: Imperceptible NLP Attacks" (IEEE S&P 2022)