Entry

What is tokenization in LLMs and why does it matter?

How to answer it in an AI engineer interview: what is being tested, a step-by-step framework, a sample answer and the mistakes to avoid.

$19.99 on Gumroad, instant download40% off with code EARLYBF until Nov 3, 11:59 PM PTEARLYBF: 40% off until Nov 3

Smaller start: Score your answers against 50 rubrics, $9. 50 AI engineer questions, one rubric each, PDF on Gumroad.

Practiced one out loud? Paste your answer into the free self-check and get a score in 30 seconds

What the interviewer is testing

Whether you know that models see tokens, not characters or words, and can connect that to practical consequences: cost, context limits, multilingual products and strange errors.

Answer framework

  1. Define it: text is split into subword units by an algorithm such as byte-pair encoding (BPE) or a unigram model (SentencePiece), and each unit maps to an ID.
  2. Cost and limits: pricing, latency and the context window are all counted in tokens.
  3. Languages: the same content can take noticeably more tokens in some non-English languages, which raises cost and uses more context.
  4. Failure modes: counting letters, reversing strings and long-number arithmetic are hard because the model never sees individual characters.
  5. Practical habit: measure token counts with the model's own tokenizer when budgeting prompts.

Sample answer

Tokenization turns text into the integer IDs the model actually reads. Modern LLMs use subword tokenizers such as BPE: frequent words become a single token, rarer words are split into pieces, and anything can still be represented through byte-level fallbacks.

It matters in three practical ways. First, everything is metered in tokens: price, latency and the context window. Second, token efficiency differs by language and by content type, so a product serving several languages, or a lot of code or JSON, can cost more per request than an English-only estimate suggests. Third, it explains failures that look odd from the outside. A model may miscount the letters in a word or slip on arithmetic with long numbers because those characters are bundled into tokens it cannot look inside.

When I budget a prompt I count with the target model's tokenizer rather than estimating from word counts, because tokenizers differ between model families.

Likely follow-ups

Why can an LLM fail to count the letters in a word? It sees tokens, not characters, so the letters inside a token are not directly visible to it.

Common mistakes

The PlaybookWant the full method?

The 0 to 1 AI Engineer Interview Playbook covers the answer frameworks, system-design walkthroughs and an 8-week plan.

Get the playbook 40% off with code EARLYBF until Nov 3, 11:59 PM PTEARLYBF: 40% off until Nov 3

Smaller start: Score your answers against 50 rubrics, $9. 50 AI engineer questions, one rubric each, PDF on Gumroad.

Interviewing for PM or TPM? See the full PM package, $59 on Gumroad: a resume system, a PM, TPM and PGM interview handbook, a 1:1 cheat sheet and a PM playbook. PM and TPM content, not AI engineer prep.

Related questions

Based on question #6 in the full question bank.