Skip to content
MAMasterAI Now
LLM Internals11 min read

What Counts as One Token in BPE? A Walkthrough

See how "unbelievable" splits into BPE subword tokens, then use a rule-of-thumb checklist to predict token counts before you run a token counter.

By MasterAI Now Team

A token in BPE (Byte Pair Encoding) is not a word but a chunk of text — often a subword, a single character, or even a byte fragment — produced by repeatedly merging the most frequent adjacent symbol pairs in a training corpus, so a word like "unbelievable" typically splits into a handful of pieces such as un + believ + able rather than one token. What counts as "one token" is therefore whatever string occupies a single slot in the model's learned vocabulary. This walkthrough shows how that vocabulary gets built and gives you a checklist for predicting the splits before you count them.

Why "One Token" Is Not One Word

A token is the atomic unit a language model reads and writes. Before any text reaches the model's neural network, a tokenizer converts it into a sequence of integer IDs, each ID pointing at one entry in a fixed vocabulary. That vocabulary is usually a few tens of thousands to a few hundred thousand entries; an estimate of 30,000–200,000 covers most common setups, but the exact size depends entirely on the model. The key point: the tokenizer must be able to represent any input, including typos, emoji, and code, using only those entries. A pure word-level vocabulary would fail on unseen words, and a pure character-level vocabulary would make sequences painfully long. BPE sits between the two.

The term "token" is also overloaded. In everyday speech it means a word; in tokenizer terminology it means one vocabulary entry. A single word can map to one token (the often does), several tokens (unbelievable), or — for rare or non-Latin scripts — many tokens, sometimes one per byte. Practitioners care because token counts drive API billing, context-window limits, and latency: fewer tokens per word means cheaper, longer inputs.

How BPE Builds Subword Units from Frequency

BPE starts from a base alphabet — classically characters, or in byte-level variants the 256 possible bytes, which guarantees every string is representable. It then runs a simple loop: count every adjacent pair of symbols across the training corpus, merge the most frequent pair into a new symbol, and repeat. Each merge adds one entry to the vocabulary. The algorithm is greedy and frequency-driven, so common strings like th, ing, or able get merged early and end up as single tokens, while rare strings stay fragmented.

A toy illustration makes the mechanics concrete. Suppose the corpus contains the word low five times, lower twice, and newest six times, with end-of-word marked by a boundary symbol (commonly written </w>):

l o w </w>        x5
l o w e r </w>    x2
n e w e s t </w>  x6

Pair counts include e w appearing 6 times and w </w> appearing 5 times. If e w wins the first merge, n e w e s t </w> becomes n ew e s t </w>, and the next round counts pairs like ew e and s t. Every merge reshapes the pair statistics, so the order of merges matters. After enough merges, frequent fragments — including word-initial ones like un — become standalone vocabulary items.

Two consequences follow. First, BPE is deterministic given a fixed vocabulary and merge list: the same tokenizer always splits the same string the same way. Second, different training corpora produce different merge orders and therefore different splits, which is why tokenizers from different model families disagree on the same word.

Splitting "unbelievable" Step by Step

Take the word unbelievable as a test case. Training corpora contain un- prefixed words (unhappy, unclear, unknown) and -able adjectives (readable, comfortable, remarkable) frequently enough that merges like un, able, and the boundary-marked able</w> are learned early. The middle stem believ is rarer as a standalone chunk, so it tends to survive as a smaller set of pieces rather than one clean unit.

Applying a typical merge list to the string, a plausible sequence is:

u n b e l i e v a b l e </w>
un b e l i e v a b l e </w>      # merge u+n -> un
un b e l i e v able </w>         # merge a+b+l+e -> able
un b e l i e v able</w>          # merge able + </w>

leaving something close to un + believ + able. In practice the exact middle varies: some tokenizers yield un + bel + iev + able, others un + belie + vable, depending on which pairs were frequent in their training data. The stable pattern is the shape: a productive prefix, a fragmented stem, and a productive suffix — roughly 3 to 5 tokens for a word of this length, as a reasoned estimate rather than a measured figure.

The practical lesson is that splits follow morpheme-like frequency, not linguistic meaning. BPE has no notion of a prefix; un becomes a token because it appears at the start of many frequent words, and able because it appears at the end of many others. Anything in the middle that doesn't recur often enough stays chopped.

A Rule-of-Thumb Checklist for Predicting Token Splits

Before you count tokens, run this checklist against the string:

  1. Is the whole word frequent? Very common words (the, and, of) are usually one token; almost everything else splits.
  2. Does it start with a productive prefix? un, re, pre, dis, non often claim their own token.
  3. Does it end with a productive suffix? -ing, -ed, -tion, -able, -ness, -ly frequently form tokens, sometimes fused with the word boundary.
  4. Is the stem a common standalone word? If yes (believe, read), chunks of it may merge; if no, expect 2–3 fragments.
  5. Is it capitalized or mixed case? Case variants are separate vocabulary entries, so Unbelievable may split differently from unbelievable.
  6. Does it contain digits, punctuation, or symbols? These usually break the word into extra tokens; leading spaces are often attached to the following token.
  7. Is it a rare proper noun, acronym, or code identifier? Expect character-level or byte-level fragmentation — potentially one token per character or byte.
  8. Is it non-Latin script or emoji? Byte-level tokenizers may spend several tokens per character.

Apply the checklist to unbelievable: frequent prefix (yes), frequent suffix (yes), common stem (believe, yes but not frequent in this exact form), so predict 3–5 tokens. For a name like Zyxwv, predict 4–6 tokens, one per character plus a boundary. These are estimates to be verified, not guarantees — the only ground truth is the specific tokenizer's vocabulary.

FAQ

What exactly counts as one token in BPE? One entry in the tokenizer's learned vocabulary — a string of one or more characters (or bytes) that survived the merge process. It can be a full word, a subword fragment, a single character, or a byte.

Why does "unbelievable" split into multiple subword tokens instead of staying whole? Because the full string wasn't frequent enough in training to earn its own vocabulary entry, while its parts — un, able, and stem fragments — were. BPE merges by frequency, not by meaning.

Do all LLMs tokenize the same word identically? No. Each model family trains its tokenizer on its own corpus with its own merge order and vocabulary size, so splits differ across models, and sometimes across versions of the same model.

How can I check token splits before counting them with a tool? Use the tokenizer library that ships with the specific model (many are available as open-source packages) and encode the exact string, including spaces, to see the token list and count. If no tool is at hand, apply the checklist above for a rough estimate.

Does the number of tokens affect API cost and context limits? Yes. Providers typically bill per token and cap inputs by token count, so a word that costs 4 tokens consumes four times the budget of a single-token word — which is why token-count estimates matter before sending long prompts.

Splitting "unbelievable" Step by Step

BPE (byte pair encoding) is a tokenizer algorithm: it starts from small units—often individual characters or bytes—and repeatedly merges the most frequent adjacent pair into a new unit, called a merge. The result is a vocabulary of subword tokens. To tokenize a new word, the tokenizer applies those learned merges in order.

Here is a small worked example. Assume a toy vocabulary trained on a corpus where the relevant pieces are:

un, believ, able, unbeliev, believable

Assume the merge ranking (earliest learned first) is:

1. b + e -> be
2. un + believ -> unbeliev
3. unbeliev + able -> unbeliev able?  (no)

To keep the arithmetic honest, simplify to a character-level start and a defined merge list:

Merge 1: "u" + "n"      -> "un"
Merge 2: "a" + "b"      -> "ab"
Merge 3: "l" + "e"      -> "le"
Merge 4: "un" + "believ" -> "unbeliev"
Merge 5: "unbeliev" + "able" -> "unbelievable"

Starting string: u n b e l i e v a b l e (12 characters). Apply merges in order:

  • Merge 1: un b e l i e v a b l e (11 units)
  • Merge 2: un b e l i e v ab l e (10 units)
  • Merge 3: un b e l i e v ab le (9 units)

Now unbeliev is not present as an adjacent pair, because b e l i e v has not been merged. In a real tokenizer, a merge like un + believ only fires if the exact string believ already exists as a unit. So whether unbelievable becomes one token, two tokens (un + believable), or three (un + believ + able) depends entirely on which merges the training corpus produced and their rank order.

Practical takeaway: a word splits where the tokenizer lacks a merge covering that span. Frequent words tend to be whole tokens; rare words fall back to smaller pieces, down to characters.

A Rule-of-Thumb Checklist for Predicting Token Splits

Use this before you count tokens:

  1. Check word frequency. Common words are usually single tokens. Rare, technical, or coined words split more.
  2. Look for known prefixes and suffixes. un-, re-, -ing, -able, -tion often exist as standalone tokens.
  3. Respect leading spaces. Many tokenizers treat a leading space as part of the token, so " unbelievable" may differ from "unbelievable".
  4. Watch capitalization and punctuation. Unbelievable and unbelievable can split differently.
  5. Expect non-English and numeric text to split more. Digits and scripts with less training data fragment.
  6. Verify with a tokenizer tool rather than guessing.

Quick estimate formula (assumption-based, not a measured benchmark):

tokens ≈ ceil(characters / chars_per_token)

For English prose, a common planning range is roughly 3.5–4.5 characters per token; treat that as an estimate, not a guarantee. For a 12-character word like unbelievable, that gives about 3–4 tokens—consistent with a split like un + believ + able.

Code idea (pseudocode):

# conceptual only
def estimate_tokens(word, cpt=4.0):
    return max(1, round(len(word) / cpt))

Always confirm with the actual tokenizer for the model you are using, since vocabularies differ.

Frequently Asked Questions

What exactly counts as one token in BPE?

A token is a single unit that a tokenizer maps to one integer ID in its vocabulary. Under Byte Pair Encoding (BPE), that unit can be a whole word, a word fragment like "un" or "able", a single character, or even a single byte (a raw 8-bit chunk of text). So "one token" means "one entry the model looks up," not "one word."

Why does "unbelievable" split into multiple subword tokens instead of staying whole?

BPE builds its vocabulary by repeatedly merging the most frequent adjacent character pairs in its training text, so it only keeps "unbelievable" whole if that exact string appeared often enough to earn its own entry. Rarer or longer words usually stay split into pieces the model has seen frequently, such as "un", "believ", and "able." This keeps the vocabulary small while still covering any word, including ones never seen in training.

Do all LLMs tokenize the same word identically?

No. Each model family trains its own tokenizer on its own text with its own merge rules and vocabulary size, so the same word can split differently across models. Even versions within one family may differ if the tokenizer was retrained. Always check splits with the tokenizer that matches the specific model you are using.

How can I check token splits before counting them with a tool?

Use the tokenizer library that ships with your model (for example, a tokenizer loaded from the model's own files) and encode your text, then decode each ID back to text to see the pieces. Most libraries expose the tokens directly, so you can print them one by one. Run this on your real input before estimating cost or context length.

Does the number of tokens affect API cost and context limits?

Yes. Providers typically bill per token and cap how many tokens fit in the context window (the combined input and output the model can process at once). Because a word can be several tokens, longer or rarer words consume more of both budget and limit than their word count suggests. Counting tokens, not words, gives the accurate figure.

Frequently asked questions

What exactly counts as one token in BPE?

A token is a single unit that a tokenizer maps to one integer ID in its vocabulary. Under Byte Pair Encoding (BPE), that unit can be a whole word, a word fragment like "un" or "able", a single character, or even a single byte (a raw 8-bit chunk of text). So "one token" means "one entry the model looks up," not "one word."

Why does "unbelievable" split into multiple subword tokens instead of staying whole?

BPE builds its vocabulary by repeatedly merging the most frequent adjacent character pairs in its training text, so it only keeps "unbelievable" whole if that exact string appeared often enough to earn its own entry. Rarer or longer words usually stay split into pieces the model has seen frequently, such as "un", "believ", and "able." This keeps the vocabulary small while still covering any word, including ones never seen in training.

Do all LLMs tokenize the same word identically?

No. Each model family trains its own tokenizer on its own text with its own merge rules and vocabulary size, so the same word can split differently across models. Even versions within one family may differ if the tokenizer was retrained. Always check splits with the tokenizer that matches the specific model you are using.

How can I check token splits before counting them with a tool?

Use the tokenizer library that ships with your model (for example, a tokenizer loaded from the model's own files) and encode your text, then decode each ID back to text to see the pieces. Most libraries expose the tokens directly, so you can print them one by one. Run this on your real input before estimating cost or context length.

Does the number of tokens affect API cost and context limits?

Yes. Providers typically bill per token and cap how many tokens fit in the context window (the combined input and output the model can process at once). Because a word can be several tokens, longer or rarer words consume more of both budget and limit than their word count suggests. Counting tokens, not words, gives the accurate figure.