Where does the tokenizer cut?

Runtime 0:20

GPT-4o splits pineapple into two tokens. Capitalizing the first letter makes three. With one leading space, the lowercase word and the space share a single token.

Transcript and source

Visual transcript

An engraved pineapple sits above its printed name. Where does the tokenizer cut? The fruit and word split into pine and apple. Their token IDs are 52736 and 34058.

Capitalize the first letter. Pineapple splits into P, ine, and apple, with IDs 47, 514, and 34058. The final piece keeps its ID.

Return to lowercase and add one space before the word. A bracket marks the space. The fruit stays whole. The space and all nine letters share token ID 116890. The final frame lines up the three inputs and their counts of two, three, and one.

Sources

The film uses OpenAI’s o200k_base encoding for GPT-4o. The token IDs were generated with tiktoken 0.12.0. OpenAI tiktoken · Model-to-encoding mapping

Downloads and standalone player