What Is Tokenisation: The Invisible Mechanism Behind AI Costs, Quality, and Bias
Direct answer
Tokenisation is the step that splits text into the discrete units, called tokens, that a language model reads. Algorithms such as Byte Pair Encoding learn a vocabulary of subwords, so common words become one token and rare words split into several. Because models are billed and limited by token count, languages that split into more tokens cost more and fit less context. Splitting also causes errors in arithmetic and spelling.
Tokenisation is a lossy, discrete representation bottleneck. The vocabulary a tokenizer learns (through Byte Pair Encoding, WordPiece or a Unigram language model) decides how long a sequence becomes, how much attention compute it consumes, how much a request costs in different languages, and how well a model can handle arithmetic and spelling. This article explains how subword tokenisation works, where it breaks, and why it matters for AI costs, answer quality and bias.
How Subword Tokenisation Works
Byte Pair Encoding (BPE) is a bottom-up vocabulary construction algorithm: it repeatedly replaces the most frequent adjacent pair of bytes or characters with a single new token until the vocabulary reaches a target size. WordPiece builds its vocabulary by choosing merges that maximise the likelihood of the training data. A Unigram language model starts from an oversized seed vocabulary and prunes it probabilistically. Despite their differences, all three treat subword vocabulary entropy as the control that converts continuous text into a discrete sequence a transformer can process.
Related terms used throughout this article: Byte Latent Transformer (BLT), Token Tax, context rot, the lost-in-the-middle effect, vocabulary entropy, UTF-8 byte fallback, subword regularisation, input-to-output token ratio, reversible tokenisation and greedy longest-match segmentation.
A Five-Stage Tokenisation and Retrieval Pipeline
The stages below describe where tokenisation sits in a retrieval and generation pipeline.
-
Raw byte ingestion and normalisation. The pre-processor accepts UTF-8 byte streams as defined by IETF RFC 3629, rejects malformed sequences, and applies a Unicode normalisation form such as NFKC so that visually identical text does not split into different token sequences.
-
BPE subword segmentation. The tokenizer scans the byte sequence and applies merges from a ranked vocabulary table , typically tens of thousands to over a hundred thousand entries (). During training, the merge chosen at each step is the most frequent adjacent pair:
Unseen characters fall back to raw UTF-8 byte tokens, so no input is dropped as unknown and the text can be reconstructed exactly.
-
Embedding and vector indexing. Token embeddings are projected into a metric space and may be compressed with product quantisation and indexed in a Hierarchical Navigable Small World (HNSW) graph for approximate nearest-neighbour search.
-
Retrieval and reranking. Candidate passages are ranked by late-interaction scoring, and click-feedback signals can be used to demote passages that spend many tokens saying little.
-
Token telemetry and cost guardrails. The system watches the input-to-output token ratio . Requests that exceed their budget can trigger early-exit decoding or a fallback to a smaller model.
Greedy longest-match segmentation sets up a balance between vocabulary size and sequence length . A larger vocabulary shortens sequences and so reduces the number of autoregressive decoding steps, but it enlarges the softmax projection layer and spreads training signal thinly over rare tokens.
Tokenizer Families and Their Limits
Tokenizer design determines how large a sequence becomes for a given text, and sequence length drives compute. Self-attention cost grows with the square of sequence length, , so anything that inflates token counts inflates both time-to-first-token and inter-token latency.
The effect is uneven across languages. Non-Latin scripts, including Semitic, Indic and East Asian scripts, usually need several subword tokens per word where Latin text needs one or two. This multiplication, commonly called the Token Tax, is described by Lundin et al. (2025) as a factor of roughly two to seven. It raises cost, shrinks the usable context window and can lower accuracy for underrepresented languages. Raw byte models such as the Byte Latent Transformer (Meta AI, 2024) avoid a fixed subword vocabulary by grouping bytes into patches according to local entropy, and report using up to half the inference compute of comparable subword models.
| Tokenizer paradigm | Segmentation primitive | Merge or prune criterion | Out-of-vocabulary strategy |
|---|---|---|---|
| Byte Pair Encoding (BPE) | Subword pairs | Frequency-ranked greedy merge | Byte fallback to raw UTF-8 byte tokens |
| WordPiece | Subword units | Gain in language model likelihood | Character-level split with a continuation prefix |
| Unigram language model | Candidate subwords | Probabilistic pruning of a seed vocabulary | Best-path search over candidate segmentations |
| Byte Latent Transformer (BLT) | Groups of raw bytes | Local entropy of the next byte | Direct byte addressing |
The comparison below sets the same paradigms against vocabulary size, character and arithmetic precision, and cost profile.
| Paradigm | Segmentation algorithm | Typical vocabulary size | Arithmetic and character precision | Cost profile |
|---|---|---|---|---|
| Subword BPE (for example GPT-4 and LLaMA 3 tokenizers) | Frequency-ranked greedy pair merge | About 100k to 128k | Weak: words and numbers split into subword fragments, for example "straw" and "berry" | Billed per token, so inflation raises cost directly |
| WordPiece (for example BERT) | Likelihood maximisation | About 30k to 50k | Weak: digit strings split into arbitrary chunks | Small vocabularies produce more tokens per document |
| Unigram language model (for example SentencePiece and T5) | Probabilistic pruning from a seed vocabulary | About 32k to 64k | Variable: sampled splits differ between runs | Comparable to BPE, with some regularisation overhead |
| Byte-level latent models (BLT, EvaByte) | Entropy-based patching over raw bytes | None beyond the 256 byte values and latent patches | Exact: individual bytes are addressable | Avoids subword billing effects and reports lower compute |
Measuring Tokenisation: Entropy, Information Gain and Cost
Quantitative modelling treats vocabulary compression as bounded by Shannon entropy. Let a text sequence of characters be mapped to a token sequence by a tokenizer with vocabulary . The entropy of the vocabulary is:
The empirical information gain of adding a merged subword to the vocabulary is:
Greedy merging therefore maximises the mutual information between adjacent units. It shortens the token sequence at the price of a larger classification entropy in the final vocabulary projection.
The cost of a workflow
Most hosted models bill input and output tokens at different rates, with output tokens priced at a multiple of input tokens. For a document collection , the total inference expenditure is:
Here is the word count of document , is the token-to-word ratio, and are the per-token prices of the input and output tiers, and is the generative expansion factor. For standard English text the token-to-word ratio averages about 1.3 tokens per word. Because output tokens cost more than input tokens, any fragmentation that inflates the output side compounds the cost.
| Script family | Effect on the token-to-word ratio | Effect on cost |
|---|---|---|
| Latin (English baseline) | About 1.3 tokens per word | Baseline |
| Cyrillic and other lightly tokenised scripts | Higher than the English baseline | Proportionally higher for the same text |
| Devanagari, Arabic and Hebrew | Substantially higher, within the Token Tax range of roughly two to seven times reported by Lundin et al. (2025) | Cost rises roughly in step with the token count |
| Scripts with sparse training data | Highest, because few merges exist for them | Highest cost and the least context left for content |
Why Tokenisation Fails: Arithmetic, Spelling and Context Rot
Three failure patterns recur, and each traces back to how text is split.
Arithmetic and digit chunking
Subword tokenizers trained on frequency-ranked merges split multi-digit numbers into inconsistent chunks: the number 123456 may become 12, 34 and 56 in one context and 123 and 456 in another. A transformer has no persistent register for place value, so self-attention struggles to align digits across chunks of different sizes. Singh and Strouse (2024) found that right-to-left tokenisation of numbers, which aligns chunks with place value, improves arithmetic accuracy in frontier models, which identifies digit chunking as a primary cause of arithmetic errors.
Character-level blindness
Counting the occurrences of the letter r in "strawberry" is a classic failure case. The tokenizer maps the word to opaque subwords such as "straw" and "berry", so the model never receives individual characters and its lower layers cannot attend to individual letters. Byte-level models and UTF-8 byte fallback keep character-level access and avoid this class of error.
Context rot and long inputs
Chroma Research (2025) reported that retrieval fidelity degrades as input length grows, across 18 frontier language models, a pattern it called context rot. Token bloat from redundant syntactic fragments fills the active context window and contributes to the lost-in-the-middle effect, in which facts placed in the middle of a long prompt receive less attention than facts at the start or end. The practical response is to compress prompts, remove boilerplate and rerank passages before they reach the model.
| Symptom | Root cause | Affected capability | Remediation |
|---|---|---|---|
| Multi-digit arithmetic errors | Arbitrary digit boundary fragmentation | Mathematical reasoning | Right-to-left digit tokenisation or step-by-step serialisation |
| Spelling and letter-counting errors | Opaque multi-character tokens | Lexical and orthographic tasks | Byte fallback or character-level prompting |
| Token inflation in non-Latin text | Scarce vocabulary for underrepresented scripts | Multilingual retrieval and cost | Balanced multilingual vocabularies or byte-level patching |
| Long-context retrieval decay | Token dilution across a long window | Dense vector retrieval | Prompt compression and late-interaction reranking |
| Parsing failures on rare glyphs | Missing Unicode code points in the vocabulary | Ingestion and parsing | Strict UTF-8 handling per RFC 3629 with byte fallback |
Encoding and Markup Standards for Tokenised Content
Open standards keep tokenised text and the knowledge artefacts built on it interoperable. All text payloads should conform to IETF RFC 3629 for UTF-8 encoding and to IEEE 754-2019 where floating-point behaviour matters. For machine-readable metadata, the W3C JSON-LD 1.1 specification gives answer engines an unambiguous way to resolve entities without parsing free text.
An article that explains a technical topic can describe itself with a Schema.org TechArticle graph. The example below is illustrative; replace the host with your own domain.
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "TechArticle",
"@id": "https://example.com/blog/what-is-tokenisation#article",
"headline": "What Is Tokenisation? The Invisible Mechanism Behind AI Costs, Quality, and Bias",
"description": "Analysis of subword tokenisation mechanics, BPE algorithms, cross-lingual Token Tax, and inference latency economics.",
"inLanguage": "en-US",
"about": [
{
"@type": "DefinedTerm",
"name": "Byte Pair Encoding",
"alternateName": "BPE",
"description": "A subword segmentation algorithm that merges frequent byte pairs."
},
{
"@type": "DefinedTerm",
"name": "The Token Tax",
"description": "A multiplication of token counts that penalises the processing of non-Latin languages."
}
]
}
]
}| Standard authority | Specification | What it governs | How compliance is checked |
|---|---|---|---|
| W3C | JSON-LD 1.1 | Structured data graphs | Automated schema validation |
| IETF | RFC 3629 | UTF-8 encoding | Rejecting malformed byte sequences at ingestion |
| IEEE | IEEE 754-2019 | Floating-point arithmetic | Deterministic numeric tests before deployment |
References
- Tokenisation Counts — Singh and Strouse, 2024.
arXiv:2402.14823 - The Token Tax: Language Bias Built Into AI — Lundin et al., 2025.
arXiv:2501.08942 - Context Rot: Retrieval Degradation in 18 Long-Context LLMs — Chroma Research, 2025.
https://research.trychroma.com/context-rot - Byte Latent Transformer: Patches as Tokens — Meta AI Research, 2024.
arXiv:2412.09871 - EvaByte: Open-Source Byte-Level Modeling — HKU NLP, 2025.
arXiv:2502.04321 - UTF-8, a transformation format of ISO 10646 (RFC 3629) — IETF, 2003.
https://www.rfc-editor.org/rfc/rfc3629 - JSON-LD 1.1 — W3C, 2020.
https://www.w3.org/TR/json-ld11/
Cite this article
@misc{quasarank2026tokenisation,
author = {{Quasarank AI Research}},
title = {What Is Tokenisation: The Invisible Mechanism Behind AI Costs, Quality, and Bias},
year = {2026},
howpublished = {\url{https://quasarank.com/blog/what-is-tokenisation}},
note = {Published 2026-10-04}
}Quasarank AI Research. (2026, October 4). What Is Tokenisation: The Invisible Mechanism Behind AI Costs, Quality, and Bias. Quasarank. https://quasarank.com/blog/what-is-tokenisation