liveBook · Manning

Token

As explained in Starting Data Analytics with Generative AI and Python

A token is a unit of text processed by a language model, such as a word, word fragment, or punctuation mark.

A token is a unit of text a language model processes: a whole word, part of a word, or punctuation. Tokenizers vary, but a rough estimate is four tokens per three words. section 1.1

Tokenization does more than split text at spaces. For example, a tokenizer may split “don’t” into “do” and “n’t”; subword schemes can represent common words whole and break less common words into smaller pieces. Each model has its own tokenization, so tokens prepared for one model may be misleading to another. section 1.3.2

A model’s context window covers both prompt and response tokens. When the input exceeds it, early tokens can be dropped without warning, leaving the model to respond without important context. Summarizing key findings can help keep them in view. section 1.1 section 1.3.2

How Starting Data Analytics with Generative AI and Python covers it

How deep it goes
Explains token units, subword splitting, model-specific schemes, and context truncation, while deferring token-count estimation.
Examples
Uses “don’t” splitting into “do” and “n’t,” and compares lost context to overhearing only the end of a conversation.
What you can do after
Understand how text becomes model-specific tokens and why exceeding a context window can remove crucial information.
How it connects
Connects tokenization with subword tokenization and context windows.

Also explained in

Compare how 31 books explain token →

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.