Hypothetical scenario. Priya uploads a short-looking policy and Northwind's assistant rejects the request as too large. The document has few pages, but a model interface counts tokens rather than pages. Text must first pass through a particular tokenizer before its input size is known.
A character is not the model's unit
People see letters, words and paragraphs. Computers represent text through an encoding, and tokenizers turn that representation into units from a vocabulary. A token can represent a complete word, part of a word, punctuation or another unit determined by the tokenizer. Different languages, scripts and formatting can yield different token counts for similar-looking passages.
A vocabulary assigns identifiers to those units. An ID is a label used to select the corresponding representation; it is not a magnitude measuring meaning. Token 200 is not twice as meaningful as token 100. A model and its tokenizer must agree on the mapping, or the same integer sequence would refer to different units.
Subword schemes help handle uncommon words without needing a separate vocabulary entry for every possible word. They reuse pieces across words. The segmentation is learned or constructed according to the tokenizer's rules, rather than chosen from a dictionary by a reader looking at syllables.
Trace a deliberately small vocabulary
Illustrative split. Choose the word “unhappiness” and a fictional tokenizer that splits it into un | happi | ness. Assign the pieces arbitrary toy IDs 17, 42 and 9. The input word becomes the sequence [17, 42, 9], containing three tokens. This is not a claim about the segmentation or IDs of any real deployed tokenizer.
Decoding uses the agreed vocabulary and rules to map those IDs back toward text. For the chosen pieces, joining “un”, “happi” and “ness” reconstructs “unhappiness”. An actual tokenizer may instead use different pieces, handle spaces explicitly or operate through byte representations. Always name the tokenizer before treating an observed count as a property of the text alone.
The specific spelling “happi” illustrates that subword units need not be standalone dictionary words. Their job is to support a vocabulary and encoding scheme. Treating token pieces as grammatical word parts can lead to mistaken claims about what a model “understands” merely from a segmentation.
Why BPE merges frequent pairs
Byte-pair encoding, or BPE, is a family of tokenization approaches that builds larger units through repeated pair merges. In a simplified training description, count adjacent symbol pairs in a corpus, merge a frequently occurring pair and repeat according to the chosen vocabulary budget. The learned merge rules are later applied when encoding new text.
In the wild. Sennrich, Haddow and Birch's subword paper applies BPE-style segmentation to neural machine translation so rare words can be represented through subword units. Its result concerns that translation setup; it does not establish that all modern tokenizers use identical preprocessing, vocabulary or merge rules.
The model architecture consumes numerical representations derived from token identities, not the printed characters alone. An embedding lookup maps each ID to a learned vector. The next foundation explains what it means to compare vectors; this chapter's boundary is earlier: which token sequence is presented in the first place?
Budget the whole request
Toy context budget. Choose a 4,000-token allowance for the combined sequence under this example's rules. Reserve 800 tokens for instructions, 2,200 for source material and 600 for the answer. The total is 800 + 2,200 + 600 = 3,600, leaving 4,000 − 3,600 = 400 tokens for the remaining counted content and margin.
If conversation history adds 500 tokens, the total becomes 4,100, exceeding the allowance by 100. Removing a decorative paragraph might help only if its token count covers the excess. The application should count the actual serialized request, including role markers or other framing where the interface's rules count them, rather than assuming the visible document is the entire input.
Token counts can also affect billed usage, but the price and charging rules belong to a particular provider and request type. A toy input of one thousand tokens is not automatically a real currency cost. Keeping quantity separate from price makes it possible to compare workloads without inventing a pricing fact.
Token count and byte count are separate units. One byte contains eight bits. A chosen representation using two bytes per stored number uses 2 × 8 = 16 bits per number; multiplying a count of stored values by bytes per value gives payload bytes. It does not give the number of text tokens. Keep these units explicit when the course later counts model-cache memory.
A token is not a word
Misconception: every token corresponds to one word, so word count predicts the request budget exactly. A word may occupy multiple tokens, and formatting can matter. Page count is even less direct because font size and layout can change without changing the underlying text.
Use tokenizer-aware accounting when choosing document slices, preserving important evidence or comparing model migrations. Count with the exact tokenizer and interface you will use. Token efficiency is one consideration; an aggressively shortened request that removes the decisive policy clause can fit perfectly and still fail the user's task.
Check yourself
Are IDs 17 and 42 close in meaning because their numbers are nearby?
No. Vocabulary IDs are labels. Their learned vectors, context and model computations determine useful relationships, not integer proximity.
The toy word has three pieces. Will every tokenizer also produce three?
No. The split and IDs are explicitly illustrative. Actual preprocessing, vocabulary and merge rules determine the encoded sequence.
Does the 3,600-token budget fit after adding 500 history tokens?
No. It becomes 4,100 against the chosen 4,000 allowance. The overrun is 100 tokens before accounting for any additional framing.
Go deeper
- Video — watch first: Let’s build the GPT Tokenizer — Andrej Karpathy. Watch first for vocabulary construction and why text length is tokenizer-dependent.
- Book chapter: Build a Large Language Model (From Scratch) — chapter 2, Working with text data — Sebastian Raschka. Follow the text-to-token representation argument before the implementation details.
- Primary paper: Neural Machine Translation of Rare Words with Subword Units — Rico Sennrich, Barry Haddow and Alexandra Birch. The original subword application explains why rare words need reusable pieces.