AI Glossary / AI foundations / Beginner
Token
Definition
A token is a unit of information that an AI model processes. For a text-based language model, it can represent a word, part of a word, punctuation or other text. A tokenizer converts text into these units. A token is not necessarily one word or one character.
What it means
When you type a question, you see sentences. The model receives a representation of those sentences built from tokens. This explains capacity measurements in tokens rather than pages or words.
The boundaries depend on the tokenizer. A familiar word might fit into one token, while an unusual name might need several. Spaces, punctuation, symbols and differences between languages can also affect the result. An English word-count rule cannot reliably predict the count for every language or document.
Reading length and processing length are different. A short-looking table of identifiers may consume more tokens than you expect. Conversely, a familiar phrase may be represented compactly. Measure with the relevant tokenizer when the exact count matters.
How it works
A text tokenizer follows a defined set of rules and a vocabulary. It divides or encodes the text into pieces, then represents those pieces using numerical identifiers. The model works with numerical representations associated with those identifiers rather than reading the displayed letters as a person would.
Many tokenizers use pieces smaller than whole words. This allows unfamiliar words to be represented using reusable parts. Other approaches work with words, characters or bytes. You need not master these algorithms, but systems do not all count identically.
During text generation, the system produces tokens that are converted back into readable output. Input and output both matter when planning a request. Instructions, supplied documents and conversation history may occupy space alongside your latest question. The exact accounting rules depend on the application.
Three practical examples
Customer service: a shop measures the tokens in its standard instructions and a typical customer conversation before deciding how much order information to include.
Personal study: a learner compares a short chapter summary with the complete chapter. The summary leaves more room for questions, but may omit details needed for a careful answer.
Multilingual publishing: an editor checks actual token counts for English and Japanese versions of a leaflet instead of assuming equal counts because they convey similar information.
Think of it this way
Think of packing a message into labeled building blocks. Some blocks hold complete words; others hold smaller pieces. The number of blocks depends on the available shapes, not just the number of words you intended to say.
Tokenization is a representation, not a judgment about importance. One token can contribute to an essential fact or to an irrelevant sentence.
Worked example
Planning room for an answer
Consider an invented text application with a combined allowance of 5,000 tokens. Its instructions use 400 tokens, the current question uses 100, and selected document excerpts use 3,000. Assume these counts already include every input component in this simplified example.
The input total is 400 + 100 + 3,000 = 3,500 tokens. That leaves 5,000 − 3,500 = 1,500 for output. If the desired output allowance is 1,000, there are 500 tokens of spare capacity.
Now another excerpt adds 700 tokens. Input becomes 4,200; adding the planned 1,000 output gives 5,200, exceeding the allowance by 200. The team must reduce input, reduce its output allowance or use a different arrangement.
These figures illustrate budgeting, not a real product limit. They do not establish a word count, response quality or a price. Some systems account for additional processing separately, so check their own usage information.
Illustrative case study
Fictional case: Cedar Languages prepares an assistant that explains community-event notices in several languages. The team initially estimates capacity from English word counts. Notices containing unfamiliar place names and mixed scripts do not fit those estimates consistently.
The team measures complete requests and checks that shortening preserves essential details. It removes repeated introductions before removing dates, eligibility rules or accessibility information. Reviewers then check the generated notices against the originals.
This invented case shows why counting and editing are separate jobs. A shorter input is useful only if it preserves what the answer needs. No measured saving or translation improvement is claimed.
Common misconceptions and mistakes
A token equals a word. Often it does not; word fragments and punctuation are common examples.
Equal meaning means equal counts. Two languages or two phrasings can communicate the same idea with different token counts.
More tokens guarantee a better answer. Extra irrelevant material can distract from the task, while overly aggressive shortening can remove necessary evidence.
Token limits are permission limits. They control processing capacity, not whether information may be shared. Privacy and access decisions remain separate.
Business use
Token awareness helps teams plan document processing, conversation length and application usage. Start by measuring representative requests, including realistic attachments and history, rather than one unusually tidy demonstration.
Keep the business objective visible. Removing a repeated greeting may be harmless; removing an exception from a refund policy may change the answer. Compare usefulness and factual completeness alongside the count.
When evaluating costs, use the chosen service's current accounting and pricing information. Token counts alone do not determine a bill, and this glossary provides no universal conversion from tokens to money or staff time.
People also ask
Can I count tokens by counting spaces?
No. Spaces do not reliably identify token boundaries, particularly across languages and tokenizer designs.
Does changing a name change the count?
It can. A different spelling may be divided into a different set of pieces.
Are tokens only for text?
No. AI systems can represent other kinds of information in token-like units. This entry explains text tokenization; image and audio accounting require their own documentation.
Check your understanding
A document contains 800 words. Can you conclude that it uses 800 tokens and fits a limit of 900 tokens?
Answer: No. The tokenizer determines the count. Measure the document and include the other input components before deciding whether it fits.
Related terms
- Tokenizer
- Context window
- Language model
- Subwords
- Vocabulary
- Prompt
- input tokens
- output tokens
- subword
Learn next
Read context window next. Compare the same short message in two phrasings using a tokenizer matched to your chosen system. Record the counts, then check that the meaning has not changed.
More in AI foundations
- Artificial intelligence - Artificial intelligence, or AI, is the field of building and studying computational systems that perform tasks involving abilities such as perception...
- Generative AI - Generative AI is artificial intelligence that produces content, such as text, pictures, audio, video or computer code, using patterns learned from data.
- Large language model - A large language model, or LLM, is a machine-learning model trained on extensive language data to learn patterns that help it process or generate language.
- AI agent - An AI agent is a system that uses information about its environment to choose and carry out actions towards a task or objective.
- Machine learning - Machine learning is the study and practice of creating systems that learn useful patterns from data or experience to perform a task.
- Hallucination - In AI, a hallucination is generated content that is false, unsupported or inconsistent with the information it is supposed to reflect, often presented...
Sources
Hugging Face, Tokenization algorithms: https://huggingface.co/docs/transformers/tokenizer_summary . Primary documentation for word, subword, character and byte-based distinctions.
Google, SentencePiece documentation: https://github.com/google/sentencepiece . Primary implementation documentation for language-independent text processing and token identifiers. Sources consulted for concepts; all budgeting figures and the fictional case are original.
Previous: Toeplitz matrix Next: Token-mixing