# 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.

AI and LLM interview question Q003, LLM fundamentals. Beginner, very common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/what-is-a-token

## Say it in 30 seconds

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.

## Say it in 2 minutes

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.

- **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.

*Diagram, Two ways to read a new word: A new word in a chat either misses a fixed word list, or gets split into known pieces the model can work with. The reply can only be right if the meaning reached the model.*
1. The word is missing from the list, so it becomes an unknown token.
2. The tokenizer breaks it into pieces it does know.
3. The model gets a blank where the meaning should be.
4. The model gets three known pieces it can work with.
5. The 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.

```python
# 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:

```text
['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.

*Diagram, From a message to a bill: A message goes to the tokenizer, each piece is counted, and the count sets what the request uses, what it can fit and what it costs. Measure real messages with the model's own counter.*
1. The whole message goes to the tokenizer first.
2. Each piece it produces becomes one token in the count.
3. The 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." Better: A 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." Better: A 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." Better: Simple 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?

A. We counted tokens with the model's own tool on 500 real chats.
B. A new product code splits into known pieces, so the model still gets parts it can read.
C. One word is one token, so our 2,000 word estimate is the monthly budget.
D. The Spanish version may use a different number of tokens for the same reply.

**Answer:** C. A word is not always one token. Rare or new words split into several, and a word count is only a rough guide. Budget from counts taken with the model's own tool.

**Quick check:** A chatbot meets a new product name that its word list never saw. What should happen?

A. Stop the chat with an error
B. Split the name into known pieces the model can still work with
C. Drop the name before the model sees it
D. Send only its first letter to save tokens

**Answer:** B. Known pieces give the model parts it can work with for a name the list never saw. Failing the chat, dropping the name or sending one letter all lose what the customer asked.

## Can you answer these from memory?

**Flash cards**

- **What is a token?** A small piece of text the model reads: a word, part of a word, or a punctuation mark.
- **Why not whole words?** A fixed word list misses new names and typos, and pieces give the model parts to work with.
- **What does a tokenizer do?** Cuts text into known pieces, then gives each piece a number for the model.
- **What is the trade-off of pieces?** More tokens per message, but the model still gets parts it can work with for rare words.
- **Are tokens the same as words?** No. Token counts and word counts differ, so measure with the model's counter.
- **What do tokens set?** The usage, the limits and the cost of each request.

## Likely follow-up questions

- Q004 How do tokenizers like BPE, WordPiece and SentencePiece work? https://designervenkat.online/interview/ai/how-do-tokenizers-work-bpe-wordpiece-sentencepiece
- Q005 Why do token counts differ across languages and models? https://designervenkat.online/interview/ai/why-do-token-counts-differ-across-languages-and-models
- Q006 What is an embedding? https://designervenkat.online/interview/ai/what-is-an-embedding
- Q008 What is a context window? https://designervenkat.online/interview/ai/what-is-a-context-window
- Q030 Why are input and output tokens priced differently? https://designervenkat.online/interview/ai/why-are-input-and-output-tokens-priced-differently
- Q040 How do you estimate the token count of a text? https://designervenkat.online/interview/ai/how-do-you-estimate-the-token-count-of-a-text

## Learn it in depth

- [Tokenization](https://designervenkat.online/learn/machine-learning/tokenization)
- [Tokens](https://designervenkat.online/learn/ai-engineering/tokens)
