The basic idea
A token in AI is a unit of data that an artificial-intelligence model processes. In language models, a token is usually a short sequence of characters, such as a complete word, part of a word, punctuation mark, space-related pattern, or special control symbol. The model does not read text directly as humans do; it first converts text into tokens, then converts those tokens into numerical identifiers that a neural network can process. What are tokens and how to count them? Key concepts | OpenAI API
For example, the sentence:
AI models learn from text.
might be divided into pieces resembling:
AI · models · learn · from · text · .
The exact division depends on the model’s tokenizer. A token is therefore not necessarily a word. A short word may be one token, a long or uncommon word may be divided into several tokens, and punctuation or whitespace may be represented separately or as part of a neighboring token.
In everyday AI discussions, “tokens” most often refers to the units used by large language models (LLMs) such as text-generation and embedding models. The same word can have other meanings in computer security, cryptocurrency, databases, and software systems, but those meanings are different from language-model tokens.
How tokenization works
Tokenization is the process of converting an input string into a sequence of tokens. A tokenizer applies rules learned or designed when the model was created. It then maps each token to an integer called a token ID. The model uses the resulting sequence of IDs as its input.
A simplified processing pipeline looks like this:
- A user supplies text, such as a question.
- The tokenizer divides the text into token pieces.
- Each piece is mapped to a token ID.
- The model converts the IDs into vectors called embeddings.
- The neural network processes the vectors in context.
- For a generative model, the system predicts a next token.
- The predicted token is converted back into text.
- This process repeats until the response ends or a generation limit is reached.
The model generates text one token at a time in a process commonly called autoregressive generation. At each step, it estimates probabilities for possible next tokens based on the preceding tokens. It does not generally retrieve a whole prewritten sentence and paste it into the answer; it selects or samples successive pieces according to its learned parameters and the generation settings.
Tokenizers commonly use subword methods. Widely used approaches include byte-pair encoding (BPE), WordPiece, and Unigram tokenization. These methods balance two competing goals: keeping frequent text patterns compact while still being able to represent unusual words, names, misspellings, symbols, and previously unseen combinations. Tokenizer Tokenization algorithms
Why a word may become several tokens
A tokenizer’s vocabulary contains a finite set of known pieces. Frequent words and character sequences can receive their own tokens, while rare words may be broken into smaller units. For instance, a long technical term might be represented as a combination of a prefix, stem, and suffix rather than as one whole token.
Token boundaries may also reflect spaces. In some tokenization systems, the token for a word includes the space preceding it. Consequently, hello world and helloworld can produce different token sequences even though they contain similar letters.
Other factors that commonly affect token counts include:
- Word frequency: common words and phrases are often encoded efficiently.
- Word length: long words frequently require multiple pieces.
- Spelling and capitalization: unusual capitalization or misspellings may increase the count.
- Punctuation: commas, quotation marks, brackets, and periods may use separate tokens or combine with nearby text.
- Numbers: a number may be represented as one piece or several, depending on its digits and formatting.
- Programming code: indentation, operators, variable names, and syntax can tokenize differently from ordinary prose.
- Language: languages with different writing systems or less representation in a model’s tokenizer may use more tokens for the same broad meaning.
- Emoji and special characters: these can be split into multiple pieces, particularly when they are represented by several underlying Unicode code points.
This is why token estimates based only on word counts are approximate. A rough rule such as “one token is a few characters” can be useful for intuition in some English text, but it is not a reliable universal conversion. The tokenizer used by the particular model is the authoritative source.
Tokens, token IDs, and embeddings
A token has several related but distinct forms:
| Form | Meaning |
|---|---|
| Text piece | The human-readable character sequence, such as part of a word |
| Token ID | An integer assigned to that piece in the tokenizer’s vocabulary |
| Embedding | A numerical vector used by the neural network as a representation of the token |
| Model output | A probability distribution over possible next token IDs |
The token itself is not the same thing as its ID. For example, a tokenizer might map a particular text fragment to an integer such as 1842; that number is only an index in that model’s vocabulary. It does not carry a universal meaning across models. The same text can have a different token ID, or even a different number of tokens, when processed by another tokenizer.
After tokenization, the model looks up or calculates a vector representation for each token. These vectors allow the neural network to detect relationships among words and pieces of text. The model also uses positional information so that it can distinguish, for example, “the cat chased the dog” from “the dog chased the cat.” Meaning comes from patterns among many tokens and their positions, not from each token acting as a complete dictionary definition.
What tokens are used for
Input and output
Tokens are used for both sides of a language-model interaction:
- Input tokens are the tokens in the user’s prompt, system instructions, conversation history, attached text, and other information supplied to the model.
- Output tokens are the tokens generated in the model’s response.
- Total tokens generally refers to the combined input and output, although exact accounting can depend on the provider and API format.
A short prompt can produce a long response, so input-token count and output-token count should be considered separately when managing limits or usage. In a chat application, earlier messages may also remain in the model’s supplied context and contribute to the input even if they are not visible in the latest message.
Context windows
A model’s context window is the maximum amount of tokenized information it can consider in one request or generation context. It includes some combination of instructions, conversation history, retrieved documents, tool results, and the new output. The precise limit varies by model and service.
If a prompt is too large, the application may need to shorten it, remove older conversation turns, summarize material, split a document into chunks, or retrieve only the most relevant passages. Token counting is therefore important in applications that process long documents or maintain lengthy conversations. Some APIs provide a token-counting method so developers can estimate usage before sending a request. Token counting - Claude Platform Docs Context windows - Claude Platform Docs
A larger context window does not mean that every detail will be used equally well. More material can introduce irrelevant information, repeated instructions, or competing facts. Good context design usually combines appropriate chunking, clear structure, and selective retrieval rather than simply placing every available document in the prompt.
Billing and rate limits
Many AI providers measure text-model usage in tokens. Pricing and quotas are provider-, model-, and plan-specific, so token count is not itself a universal cost. Some services charge differently for input and output, while others include separate treatment for cached content, batch processing, or other operations. The applicable provider documentation should be used for current rates and counting rules.
Token counts can also affect throughput and rate limits. A request with a large prompt or lengthy response may consume more of an account’s permitted usage than a short request. Applications often set a maximum output-token value to control response length, latency, and resource use.
Training
During training, a language model is exposed to large collections of tokenized text. The model adjusts its parameters to learn statistical relationships among token sequences. Tokenization affects this learning process: a concept that is consistently represented by compact, meaningful pieces may be easier to model than text that is fragmented into many unusual pieces.
Tokenization does not give the model human-like understanding by itself. It is an interface between raw data and the neural network. The model’s capabilities depend on its architecture, training data, objectives, parameters, and inference process as well as on the tokenizer.
What are special tokens?
Not every token corresponds to ordinary visible text. A tokenizer may define special tokens that mark structural information, such as:
- the beginning or end of a sequence;
- padding used to align sequences in a batch;
- an unknown or unrecognized item;
- a boundary between messages or roles;
- a separator between segments;
- a tool call or other structured event.
Some special tokens are inserted automatically by an API or model wrapper. Others may be visible only in an internal representation. Their exact names and behavior are model-specific, so developers should not assume that a token with a particular name works identically across systems.
In chat-based systems, a visible conversation is often transformed into a structured sequence containing role labels, message boundaries, and content. As a result, the token count may be slightly higher than the count obtained by tokenizing only the visible words.
Tokens are not words, parameters, or characters
These terms are related but should not be confused:
- A character is a unit of written text, such as
A,?, or a particular Unicode symbol. - A word is a linguistic unit separated according to language- and context-dependent rules.
- A token is a model-specific unit produced by a tokenizer.
- A parameter is a learned numerical value inside the neural network.
- A context window is a limit on how many tokens the model can process together.
A model with billions of parameters does not necessarily have a vocabulary of billions of tokens. The vocabulary is the set of token pieces known to the tokenizer; parameters are the values learned by the model. Likewise, a document containing 1,000 words may contain fewer or more than 1,000 tokens depending on its language, formatting, and vocabulary.
Tokens in languages, code, and other data
Tokenization is especially important for multilingual applications. A sentence with the same approximate meaning can produce different token counts in different languages. Writing systems, character encoding, morphology, and the tokenizer’s training data all influence the result. Token count should therefore not be treated as a direct measure of meaning, reading difficulty, or translation quality.
Source code is tokenized too, but code tokenization is not identical to the tokens used by a compiler or programming-language parser. An AI model may split a function name, operator, indentation sequence, or string literal into several model tokens. A model can still learn useful programming patterns, but token budgets for code can differ substantially from those for ordinary prose.
Modern multimodal systems may also represent non-text inputs with model-specific units sometimes called tokens. Images, audio, and video can be converted into patches, feature vectors, or other discrete or continuous representations. These are conceptually related to text tokens because they are units consumed by a model, but they are not necessarily interchangeable with the text tokens used by a language tokenizer. The provider’s documentation determines how such inputs count toward a context limit or usage measure.
How to count tokens
The most accurate approach is to use the tokenizer associated with the exact model or API being used. A tokenizer tool can show:
- the token pieces;
- the token IDs;
- the number of input tokens;
- the estimated number of output tokens;
- the effect of formatting, whitespace, and special message structure.
For rough planning, count more conservatively when text contains source code, tables, long identifiers, many numbers, non-English writing, unusual symbols, or copied markup. A prompt that fits comfortably in one model may exceed the context limit of another because tokenizers and limits differ.
When building an application, token counting should be performed on the final serialized request rather than on an informal copy of the text. System messages, role markers, JSON wrappers, retrieved passages, tool definitions, and conversation history can all add tokens. Output limits should also leave room for the response rather than consuming the entire available context with the prompt.
Common misconceptions
“One token equals one word”
Usually false. Some words are one token, but many are split, and punctuation or spaces can also count. Token count is a property of the model’s tokenizer, not of ordinary grammar.
“Tokens are pieces of meaning”
Not necessarily. A token may correspond to a meaningful word, but it may also be a fragment such as a suffix, a space-plus-word pattern, or a punctuation mark. Meaning is represented through relationships among tokens in context.
“More tokens always mean a better answer”
No. More tokens may provide useful detail, but they can also add noise, consume limits, increase latency, and make important information harder to locate. Concise, relevant context is often more effective than indiscriminately increasing the prompt.
“All AI models use the same tokens”
No. Tokenizers are model- and provider-dependent. Even models based on similar architectures can use different vocabularies, token boundaries, special tokens, and counting conventions.
“A token is the model’s memory”
A token is an input or output unit, not a memory cell. The model’s learned knowledge is distributed across its parameters, while the current prompt and conversation are represented in the active context. A context window limits the supplied sequence; it does not by itself describe everything the model has learned.
In short, tokens in AI are the model’s basic pieces of processable data. For language models, they connect human-readable text to numerical computation, determine how prompts and responses fit within context limits, and often influence usage accounting. Understanding tokens helps explain why formatting matters, why a word-count estimate can be misleading, and why the correct tokenizer—not a universal conversion rule—is needed for precise calculations.
Sources
Defining the Token: The Fundamental Unit of AI
A token in AI is the basic, discrete unit of data that a neural network processes, analyzes, and generates. In natural language processing (NLP) and large language models (LLMs), neural networks cannot directly interpret human text, characters, or raw words as strings. Instead, incoming text is segmented into smaller numerical components—ranging from whole words and subwords to individual characters or punctuation marks—through a process called tokenization. What are tokens and how to count them? - OpenAI Help Center Understanding tokens - .NET | Microsoft Learn
Once broken into tokens, each unit is mapped to a unique integer ID within the model's fixed vocabulary and subsequently transformed into a dense mathematical vector known as an embedding. Tokens serve as both the fundamental semantic currency during model training and inference and the computational metric used to define context window limits, throughput speed, and API pricing structures across AI platforms. Understanding tokens - .NET | Microsoft Learn What Are AI Tokens? The Language and Currency Powering Modern AI
Raw Text: "Understanding tokenization is essential."
│
Tokenization: ["Understand", "ing", " token", "ization", " is", " essential", "."]
│
Token IDs: [14821, 292, 11241, 1634, 374, 8491, 13]
│
Vector Space: [[0.024, -0.912, ...], [0.418, 0.119, ...], ...]The Mechanics of Tokenization
Tokenization sits at the interface between human-readable data and machine learning architectures. The transformation from raw text into numerical representations follows a sequence of deterministic steps before reaching the neural layers of a transformer model. Understanding tokens - .NET | Microsoft Learn
The Text-to-Vector Pipeline
- Text Normalization and Pre-Tokenization: The raw input string is cleaned and split into preliminary boundaries, such as whitespace or language-specific delimiters. Case folding, Unicode normalization (e.g., NFC/NFKC), and whitespace preservation occur at this phase.
- Subword Segmentation: The tokenizer applies a statistical model against a pre-compiled vocabulary to split strings into optimal subword pieces.
- Vocabulary Lookup (Token IDs): Each token string corresponds to an entry in a lookup table. For instance, in a model with a 100,000-token vocabulary, each token maps directly to an index between and .
- Vector Embedding: The token IDs are passed to the model's embedding matrix. An ID of index retrieves the -th row of the matrix, creating a high-dimensional vector of dimension (e.g., 4,096 dimensions in many standard models) that encodes the semantic and syntactic properties of the unit. Understanding tokens - .NET | Microsoft Learn
Token Granularity: Words, Characters, and Subwords
Tokenization methods have evolved significantly to balance vocabulary size with semantic expressiveness.
| Granularity Level | How It Works | Advantages | Disadvantages |
|---|---|---|---|
| Word-Level | Splits text on whitespace and punctuation marks. | Direct semantic alignment; intuitive human interpretation. | Massive vocabulary size ( words); fails on out-of-vocabulary (OOV) terms, typos, or rare compounds. |
| Character-Level | Splits text into individual characters (letters, digits, symbols). | Extremely small vocabulary (); zero OOV issues. | Long sequence lengths dilute contextual attention; poor per-token semantic density; high compute overhead. |
| Subword-Level | Dynamically segments common words into single tokens and rare/complex words into smaller sub-units. | Balanced vocabulary ( tokens); handles unseen words, typos, and morphologically rich languages efficiently. | Slightly more complex decoding logic; language imbalance depending on training corpus. |
Modern generative architectures rely almost universally on subword-level tokenization to achieve high computational efficiency without sacrificing vocabulary coverage. Tokenization algorithms - Hugging Face
Common Subword Tokenization Algorithms
Modern tokenizers construct their vocabularies using automated statistical algorithms optimized on massive multilingual corpora.
Byte-Pair Encoding (BPE)
Originally a data compression technique, Byte-Pair Encoding iteratively merges the most frequently co-occurring adjacent characters or character sequences in a training corpus until a predefined vocabulary size is reached. Many prominent models, including the GPT family and Llama series, use Byte-level BPE, which operates directly on raw bytes rather than Unicode characters to ensure that any arbitrary byte sequence can be processed without generating out-of-vocabulary tokens. Tokenization algorithms - Hugging Face
WordPiece
Used prominently in models such as BERT, WordPiece initializes with basic characters and incrementally adds subword pairs. Unlike BPE—which merges pairs based strictly on frequency—WordPiece selects merges that maximize the likelihood of the training data according to a probabilistic language model. Tokenization algorithms - Hugging Face
Unigram and SentencePiece
The Unigram algorithm reverses the BPE process: it begins with a vast initial vocabulary of candidate tokens and iteratively removes subwords that contribute the least to overall corpus likelihood until reaching the desired vocabulary threshold.
SentencePiece is an open-source library that treats the entire input string as a continuous sequence of raw characters, treating whitespace as an explicit symbol (e.g., _ or ) rather than relying on language-dependent pre-tokenization rules. It can implement both BPE and Unigram algorithms, making it widely used for multilingual models such as T5 and Gemma. Tokenization algorithms - Hugging Face
Tokens in Practice: Text Ratios and Modalities
Rule-of-Thumb Conversion Ratios
In standard English text processed by modern tokenizers:
- (or roughly 4 characters of text). What are tokens and how to count them? - OpenAI Help Center
- . What are tokens and how to count them? - OpenAI Help Center
However, token density varies substantially across domains and languages:
- Standard English Prose: Highly compressed. Frequent words (e.g., "the", "system", "development") are single tokens.
- Code and Markup: Punctuation-dense languages (e.g., JSON, Python, C++) consume more tokens due to indentation, brackets, variable names, and special symbols.
- Non-Latin Scripts: Languages with rich morphological inflection or non-Latin alphabets (such as Arabic, Hindi, Chinese, or Japanese) often require multiple tokens per word if the tokenizer's training corpus was predominantly English, leading to higher token usage for identical semantic content. What are tokens and how to count them? - OpenAI Help Center
Multimodal Tokens: Vision and Audio
The concept of a token extends beyond text into multimodal architectures:
- Vision Tokens: In Vision Transformers (ViTs), an image is divided into a grid of non-overlapping patches (e.g., pixels). Each patch is flattened and linearly projected into a vector embedding, serving as an image token.
- Audio Tokens: Continuous acoustic waveforms are discretized using neural audio codecs into discrete codebook indices, which are processed sequentially like text tokens.
Operational and Computational Implications
Tokens govern virtually every technical constraint and financial consideration when building and deploying AI systems.
Context Windows and Memory Complexity
Large language models operate within a strict context window (e.g., 8,192, 32,768, or 1,000,000+ tokens), representing the maximum combined sequence length of input prompts and output responses the model can process at one time.
In standard transformer attention mechanisms, the computational complexity and memory footprint of the attention layer scale quadratically with sequence length:
where is the number of tokens in the context sequence. Longer token sequences require substantially higher GPU VRAM during processing and key-value (KV) cache allocation.
API Metering and Cost
Commercial model providers bill developer usage based on token volume, separating pricing into:
- Input (Prompt) Tokens: Ingested and processed in parallel by the model's prefill phase.
- Output (Completion) Tokens: Generated autoregressively one token at a time, requiring significantly higher computational time and memory bandwidth. What are tokens and how to count them? - OpenAI Help Center What Are AI Tokens? The Language and Currency Powering Modern AI
Sources
The Basic Unit AI Models Actually Read
A token in AI is the smallest chunk of data a model reads or writes. For language models, it is a fragment of text — sometimes a whole word, sometimes part of a word, sometimes just a punctuation mark or a space. Before a model can process the sentence "Tokenization is unavoidable," a component called a tokenizer splits it into pieces, converts each piece into an integer ID, and hands the model a list of numbers rather than raw characters. Everything the model does afterwards — attention, prediction, generation — operates on those units. What are AI tokens? Definition, counting & cost | Decagon Understanding tokens - .NET | Microsoft Learn
This makes tokens simultaneously three things: the model's alphabet, the unit in which its memory limits are measured, and the unit in which commercial APIs bill you. Understanding them explains a surprising amount of otherwise mysterious AI behaviour, from why a chatbot miscounts letters to why the same prompt costs more in Japanese than in English. What Are AI Tokens? The Language and Currency Powering Modern AI
Why not just use words or letters?
The obvious alternatives both fail in instructive ways.
If a model's vocabulary were a list of whole words, it would need an entry for every word it might ever see. Human vocabularies are effectively open-ended: names, typos, URLs, product codes, inflected forms, and newly coined words appear constantly. Any fixed word list eventually meets something it cannot represent and must fall back on an "unknown" placeholder, destroying information. Word vocabularies are also brittle across languages that don't separate words with spaces.
If the vocabulary were individual characters, nothing would ever be unknown, but sequences become extremely long. A 500-word paragraph becomes roughly 3,000 units instead of 700, and because transformer attention cost grows with sequence length, this wastes compute while forcing the model to learn spelling patterns from scratch before it can learn meaning.
Subword tokenization is the compromise that won. Frequent words get their own single token; rare or novel words are decomposed into recognizable pieces. unbelievable might become un + believ + able; a rare surname might break into three or four fragments. Nothing is truly out-of-vocabulary, and common text stays compact. How tokenizers work in AI models: A beginner-friendly guide - Nebius What Is a Token in AI? An Explainer - Couchbase
How tokenizers are built
The dominant method is byte pair encoding (BPE). It began life as a data-compression algorithm described by Philip Gage in 1994 and was adapted to neural machine translation by Sennrich, Haddow and Birch, who used it to give translation systems open-vocabulary behaviour with a compact symbol set. That paper is the reason most large language models today ship with a BPE-style tokenizer. Neural Machine Translation of Rare Words with Subword ... Byte Pair Encoding: Subword Tokenization - Interactive
The training procedure is simple to describe:
- Start with a vocabulary of individual characters (or raw bytes).
- Count all adjacent symbol pairs in a large text corpus.
- Merge the most frequent pair into a new single symbol and record the merge rule.
- Repeat until the vocabulary reaches a target size.
The result is an ordered list of merge rules that can be replayed deterministically on any new string. Related families include WordPiece (used by BERT-style models, choosing merges by likelihood rather than raw frequency), SentencePiece (which trains directly on raw text without pre-splitting on whitespace, useful for Chinese, Japanese and Thai), and byte-level BPE (which starts from the 256 possible bytes so that any Unicode input, including emoji and corrupted text, is representable).
Vocabulary size is a design trade-off. Larger vocabularies mean shorter sequences and cheaper inference per unit of text, but a bigger embedding table and more parameters spent on rare entries. Modern models commonly use vocabularies in the range of tens of thousands to a few hundred thousand entries, and the exact figure differs by model family.
Tokenizers also reserve special tokens that carry structural meaning rather than text: sequence start and end markers, padding, and — in chat models — delimiters that mark where the system instruction ends and the user turn begins. These are part of why a chat API's token count is slightly higher than a naive count of your visible message.
| Granularity | Typical unit | Sequence length | Handles unseen words |
|---|---|---|---|
| Character / byte | s, t, r | Very long | Always |
| Subword (BPE, WordPiece) | straw, berry, ing | Moderate | By decomposition |
| Whole word | strawberry | Short | Poorly |
Counting tokens in practice
There is no exact conversion between tokens and words, because it depends on the tokenizer and the text. For ordinary English, widely quoted rules of thumb are that one token is roughly four characters, roughly three-quarters of a word, so about 100 tokens per 75 words. What are tokens and how to count them? - OpenAI Help Center
Those averages degrade quickly outside typical English prose:
- Other languages. Text in languages under-represented in the tokenizer's training corpus fragments into more pieces. The same meaning can consume two to several times as many tokens, which raises both cost and effective context consumption.
- Code. Indentation, brackets, and identifiers such as
getUserByIdsplit into multiple tokens; code generally has a lower character-per-token ratio than prose. - Numbers. Long numerals are often chopped into arbitrary digit groups, which is one reason arithmetic is unreliable without tool use.
- Whitespace and formatting. Leading spaces are typically attached to the following word, so
" cat"and"cat"are usually different tokens.
For anything cost- or limit-sensitive, count tokens with the model's own tokenizer library rather than estimating from word counts. Character-based estimates are fine for rough capacity planning and misleading for tight budgets.
From tokens to predictions
Once text is tokenized, each integer ID indexes into an embedding table, retrieving a learned vector. The transformer then processes the whole sequence of vectors and produces, at the final position, a probability distribution over the entire vocabulary — a score for every possible next token. A sampling step (greedy, temperature, top-p, and so on) selects one. That token is appended to the sequence, and the process repeats.
This is the mechanical meaning of the phrase "large language models predict the next token." Generation is inherently sequential and token-by-token, which is why:
- Streaming responses appear word-fragment by word-fragment.
- Output length is capped by a maximum-tokens parameter, and hitting that cap truncates mid-sentence rather than producing a shorter, complete answer.
- Latency has two distinct components: time to process the prompt (prefill) and time per generated token (decode).
Tokens as the currency of context and cost
Every limit and price tag in a modern model API is denominated in tokens. The context window is the maximum number of tokens the model can attend to at once, counting the system prompt, conversation history, retrieved documents, tool definitions, tool results, and the response being generated. Contemporary flagship models advertise windows ranging from tens of thousands to a million or more tokens, though large windows do not guarantee uniform recall across the whole span. Long context | Gemini API - Google AI for Developers
Billing follows the same unit. Providers typically quote a price per million tokens and charge input (prompt) tokens and output (completion) tokens at different rates, with output usually more expensive because it requires a full forward pass per token. Several providers add further categories: discounted cached input tokens for repeated prefixes, and separately metered reasoning or thinking tokens that a model generates internally before its visible answer. Rates, tiers and surcharges change frequently and vary by provider, model and plan, so treat any specific figure as something to verify against current documentation. What are tokens and how to count them? - OpenAI Help Center Pricing - Claude Platform Docs
The practical consequence is that token accounting is engineering work. Long chat histories re-send the entire conversation on every turn, so cost grows roughly quadratically over a session unless you summarize, truncate, or cache. Verbose system prompts and bloated retrieved documents are paid for repeatedly.
Tokens beyond text
The concept generalizes. In vision transformers, an image is cut into fixed-size patches, each linearly projected into a vector and treated exactly like a text token; a 224×224 image split into 16×16 patches yields 196 tokens. Audio is commonly converted into spectrogram patches or into discrete codes produced by a learned audio codec, and video adds a temporal dimension on top of spatial patches. Multimodal models feed these heterogeneous token streams into a shared sequence so that attention can relate a phrase to a region of an image. Learning to tokenize in Vision Transformers How LLMs See Images, Audio, and More
This is why image and audio inputs consume context budget and appear on invoices in token units, and why a high-resolution image can cost more than a page of text.
Where tokenization leaks into behaviour
Because the model never sees letters directly, character-level tasks are structurally hard. The classic demonstration is asking how many times r appears in strawberry: if the word is tokenized as something like straw + berry, the model has no direct view of the individual characters and must rely on memorized associations. Research on this failure mode finds models handle letters that appear once within a token far better than letters repeated inside a token, which matches the tokenization explanation rather than a general reasoning deficit. Why Do Large Language Models (LLMs) Struggle to Count Letters? Why LLMs Can't Spell 'Strawberry' And Other Odd Use Cases - Runpod
Related artefacts include unreliable reversal of strings, inconsistent rhyming and syllable counting, digit-grouping errors in arithmetic, and so-called glitch tokens — rare vocabulary entries that were barely trained and can trigger strange outputs. Some are mitigated by prompting the model to work character-by-character or by delegating to a tool; none disappear entirely, because they follow from the representation itself.
A note on the word "token"
"Token" is heavily overloaded in computing, and the AI sense is unrelated to several neighbours you may encounter in the same search results:
- AI/LLM token — a unit of text or other data in a model's vocabulary (this article).
- Crypto token — a unit of value on a blockchain.
- Authentication token — a credential such as an API key or JWT used to authorize requests. Confusingly, you use an auth token to spend AI tokens.
- Compiler token — a lexical unit produced by a programming-language lexer, which is a close conceptual cousin: same idea of segmenting a stream into meaningful units, different vocabulary construction.
Keeping these separate matters when reading documentation, where a single page may mention token limits, token pricing, and bearer tokens within a few paragraphs.
Sources
- [1]What are AI tokens? Definition, counting & cost | Decagondecagon.ai
- [2]Understanding tokens - .NET | Microsoft Learnlearn.microsoft.com
- [3]What Are AI Tokens? The Language and Currency Powering Modern AIblogs.nvidia.com
- [4]How tokenizers work in AI models: A beginner-friendly guide - Nebiusnebius.com
- [5]What Is a Token in AI? An Explainer - Couchbasecouchbase.com
- [6]Neural Machine Translation of Rare Words with Subword ...aclanthology.org
- [7]Byte Pair Encoding: Subword Tokenization - Interactivembrenndoerfer.com
- [8]What are tokens and how to count them? - OpenAI Help Centerhelp.openai.com
- [9]Long context | Gemini API - Google AI for Developersai.google.dev
- [10]Pricing - Claude Platform Docsplatform.claude.com
- [11]Learning to tokenize in Vision Transformerskeras.io
- [12]How LLMs See Images, Audio, and Moreblog.bytebytego.com
- [13]Why Do Large Language Models (LLMs) Struggle to Count Letters?arxiv.org
- [14]Why LLMs Can't Spell 'Strawberry' And Other Odd Use Cases - Runpodrunpod.io