Definition

Tokenization

Tokenization converts input text into units that a model can map to integer IDs. A tokenizer can use complete words, subwords, characters, or bytes. Its vocabulary and segmentation rules determine how many tokens a string uses, so the same text can occupy different amounts of context in different models.

Count tokens with the model’s vocabulary

A toy subword vocabulary could split “rereading” into “re”, “read”, and “ing”, for a count of three. A vocabulary that contains “rereading” could encode the same word with one token. Both segmentations can reconstruct the word. When estimating context or fees, run the exact model tokenizer on the structured request, including the prompt and tool descriptions.

Subword segmentation research

Intelligence at Scale by Shashank Agarwal

Tokenization diagram from Intelligence at Scale
Diagram from chapter 5, Inside the Machine

Explained in

Chapter 5: Inside the Machine

Everything you need to know about what's happening inside the box. No PhD required.

Related terms

This is one term. The chapter is the argument.

Intelligence at Scale: 22 chapters, 65,000 words, 80-plus diagrams. Kindle, paperback and hardcover on Amazon.

Buy on Amazon.com
← All terms