What Is a Token?
What a token is, why models split text into pieces instead of whole words, and why token counts drive cost, explained simply for your AI interview.
In short
A token is a small piece of text that a model reads and writes, such as a whole word, part of a word or a punctuation mark. Models use tokens because a fixed word list cannot cover every new name, typo or product code.
11 min readBeginnerVery common · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
A token is a small piece of text that a model reads and writes. It can be a whole word, part of a word, or a punctuation mark. A fixed word list can't cover every new name, typo or product code, so text is split into smaller known pieces the model can still work with. Tokens also set the usage and cost of each request, so I measure them with the model's own counter.
A language model doesn't read letters or whole sentences the way we do. It reads tokens, which are small pieces of text. A token can be a whole word such as card, part of a word such as block inside reblocked, or a punctuation mark. Before the model sees a message, a tokenizer cuts it into tokens and gives each one a number.
Why not whole words? A word list is fixed when the model is built. Older word-level systems worked that way, so a new product code, a typo or a name the list never saw became an unknown token, and its meaning was lost. Modern tokenizers avoid that by falling back to smaller pieces, down to bytes for Unicode text. Research on translation put the problem plainly: translation is an open-vocabulary problem, so rare words get encoded as sequences of smaller units.
Tokens also drive the bill and the limits. Each request uses tokens for its input and its output, and every model can work with only so many tokens in one request. A word count is only a rough guide. OpenAI's own rule of thumb for English is about three-quarters of a word per token, and other languages can differ. So I measure real messages with the model's own counter before I promise a budget.
Some pieces carry little meaning on their own, like the ending ed. The model learns what each piece adds from how it combines with the others in context. Tokens are the units it reads, and words are the units people read.
What is a token, in plain words?
A language model reads text as tokens, not as letters or whole sentences. A tokenizer, the program that cuts text up, turns your message into a row of tokens before the model sees it. Each token has a number, and the model works with those numbers.
Think of a bank's cheque clearing system. It takes a cheque apart into the sort code, the account number and the amount, and handles each field it already knows. A support assistant does the same with words: it reads reblocked as the known parts re, block and ed.
Key words
- Token
- A small piece of text the model reads, such as a word, part of a word or a punctuation mark.
- Tokenizer
- The program that cuts text into tokens before the model sees it.
- Vocabulary
- The fixed list of pieces the tokenizer knows.
- Unknown token
- In older word-list systems, a stand-in for a word the list cannot match. Its meaning is lost.
Why not just use whole words?
Whole words look simple, but they break in real use. A chat assistant meets names, typos, product codes and slang every day. A word list built last year has no entry for them, so a model that relies on whole words cannot work with them.
Two ways to read a new word
New word in a chat
reblocked is not in the word list
Old word list
Unknown token
meaning lost from the message
Known pieces
Split into known parts
re + block + ed, parts kept
Model
sees only the tokens it is given
Reply
wrong if the meaning is missing
- 1The word is missing from the list, so it becomes an unknown token.
- 2The tokenizer breaks it into pieces it does know.
- 3The model gets a blank where the meaning should be.
- 4The model gets three known pieces it can work with.
- 5The reply is right only when the meaning reached the model.
- Whole words
Short, but brittle
Every name, typo and product code needs its own entry. In a fixed list, anything missing loses its meaning.
- Characters
Never unknown, but long
Every letter becomes a token. A long message turns into many small pieces, which uses more of the limit and costs more.
- Subword pieces
The working middle
Common words stay whole, and rare words split into known parts. The model still gets parts it can work with.
A fixed word list is a closed vocabulary: anything not on it is out. An open vocabulary means the words can be anything, so the system has to cope with new ones. The two quotes below describe this same problem, one from a research paper and one from a model maker's glossary.
“Neural machine translation (NMT) models typically operate with a fixed vocabulary, but translation is an open-vocabulary problem.”
Sennrich and co-authors (2015)
“Larger tokens improve data efficiency during inference and pretraining (and are used when possible), whereas smaller tokens allow a model to handle uncommon or never-before-seen words.”
Anthropic
How does a tokenizer split text?
Many modern tokenizers learn their pieces from a large sample of text, and keep the pieces that show up often. A 2015 paper built its splitting on byte pair encoding, a compression method. Common words end up as one token, and rare words stay as several smaller pieces.
Here is a small, runnable demo. The piece list is typed by hand and the matcher is a simple longest-match rule, so it is not real byte pair encoding. Many real tokenizers learn their pieces from text. The word list comes from a bank's support logs, and the customer's message contains a word the list never saw.
# A bank's support bot. Its word list came from last year's chats,
# so new words, like product names and typos, are missing from it.
WORDS = {"my", "card", "was", "blocked", "after", "the", "payment", "failed"}
PIECES = ["my", "card", "was", "after", "the", "payment", "fail", "failed", "re", "block", "ed", "pay", "ment"]
def whole_words(text):
# A word not in the list becomes an unknown token, and its meaning is lost.
return [w if w in WORDS else "<unk>" for w in text.lower().split()]
def pieces(text):
out = []
for word in text.lower().split():
while word:
options = [p for p in PIECES if word.startswith(p)] or [word[0]]
best = max(options, key=len) # the longest known piece wins
out.append(best)
word = word[len(best):]
return out
msg = "My card was reblocked after the payment failed"
print(whole_words(msg))
print(pieces(msg))
print(len(whole_words(msg)), len(pieces(msg)))Output
['my', 'card', 'was', '<unk>', 'after', 'the', 'payment', 'failed'] ['my', 'card', 'was', 're', 'block', 'ed', 'after', 'the', 'payment', 'failed'] 8 10
The whole-word version gave one unknown token for reblocked, so the bot lost the key word. The piece version gave three known pieces for it and used two more tokens in total. That is the trade-off: more tokens, but the model gets parts it can work with.
Tip
In an interview, name the trade-off first: pieces cost more tokens, while a fixed word list fails on anything new.
Why do token counts change by language and model?
The same text can make a different number of tokens in two places. OpenAI's guide says a word can split differently depending on its spelling, its capitals and the words around it. It also says other languages can have different relationships between characters, words and tokens. Anthropic says the number of characters a token stands for depends on the model and the language. Its glossary, checked in November 2026, also notes that its newer tokenizer (Claude 4.7 and later) produces about 30 percent more tokens for the same text.
From a message to a bill
Customer message
the text the bot must read
Tokenizer
cuts the text into known pieces
Token count
depends on language and model
Usage and cost
limits and cost follow the count
- 1The whole message goes to the tokenizer first.
- 2Each piece it produces becomes one token in the count.
- 3The count sets the usage, the limits and the cost of the request.
Worked example. A bank's support assistant handles about 40,000 chats a month, and an average chat uses about 1,200 tokens. Both figures are made up for this example. If customers write in a language that splits into more tokens, the same chats cost more, because the input and output counts go up. So the team counts real chats first and sets the budget from those counts, not from a word count.
How would you cut a support bot's token bill?
Start by measuring. Log the input and output token counts for real chats, then find the long parts: a pasted policy document, a long chat history, or a tool that returns a whole file.
- 1
Measure
Count tokens on real chats, not on the test prompts the team wrote.
- 2
Trim the input
Send only the policy section that matches the question, and keep the history short.
- 3
Limit the reply
Ask for a short answer when a short one is enough. Output tokens count toward usage too.
What does the interviewer want to hear?
A strong answer covers
- A token is a piece of text: a word, part of a word or punctuation.
- Why not whole words: a fixed list misses new and rare words, and pieces give the model parts it can work with.
- The trade-off: subword pieces mean more tokens, but the model still has parts to work with.
- Token counts change with language and model, so measure real text.
- Tokens set usage, limits and cost, so budget from real counts.
Common traps
Trap"A token is always one word."
BetterA token can be a word, part of a word or a punctuation mark. Count with the model's own tool.
Trap"Tokens and words are the same, so I can budget by word count."
BetterA word count is only a rough guide for English. Measure real text before you set a budget.
Trap"Whole words are simpler, so we should use them."
BetterSimple until a new name arrives. Subword pieces give the model parts it can work with for words the list never saw.
Can you spot the wrong assumption?
Spot the wrong line
This is from a bank's chatbot budget note. Which line is wrong?
Quick check
A chatbot meets a new product name that its word list never saw. What should happen?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
- Q004How do tokenizers like BPE, WordPiece and SentencePiece work?11 min
- Q005Why do token counts differ across languages and models?10 min
- Q006What is an embedding?11 min
- Q008What is a context window?11 min
- Q030Why are input and output tokens priced differently?11 min
- Q040How do you estimate the token count of a text?10 min
Learn it in depth
Last updated on 26 November 2026
Running an AI assistant and watching its token bill?
I design and build AI products and agents, the interface and the system behind them. Book a short call and tell me what you need to build.