liveBook · Manning

Tokenization

As explained in Starting Data Analytics with Generative AI and Python

An algorithm that divides text into the token units consumed by a language model.

Tokenization divides text into the units a generative AI model processes. A token may be a whole word, part of a word, or punctuation, depending on the tokenization method. section 1.1

Treat tokens as the model’s limited working space: both prompts and responses consume the context window. A rough average is four tokens per three words, but limits vary widely across models and implementations. section 1.1

Watch for these practical effects:

  • Long inputs can push earlier prompts, responses, or data out of the context window without an explicit warning. section 1.1
  • Summarizing a conversation and its key findings can preserve important context when token limits are tight. section 1.1

How Starting Data Analytics with Generative AI and Python covers it

How deep it goes
Defines token units and gives an average ratio, but stops short of explaining algorithm internals or comparing specific methods.
Examples
Uses words, word parts, and punctuation marks as illustrative token units.
What you can do after
Evaluate when inputs may exceed context limits and recognize truncation through inconsistent responses or forgotten exchanges.
How it connects
Connects tokenization with generative AI models, context windows, prompts, responses, truncation, and conversation summarization.

Also explained in

Compare how 25 books explain tokenization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Starting Data Analytics with Generative AI and Python. The section links point to the parts of the book it draws on.