← All Demos

From Bits to Tokens

How a tokenizer learns its vocabulary, one merge at a time.

robert@barcik.training

Text: Show:

Up to 240 characters. Nothing leaves your browser.

Sequence length
0
Possible values (vocabulary)
0
Neural networks prefer a short sequence with many possible values.
Keyboard: ← → step · Home / End · Space plays

Vocabulary: tokens minted so far

Tokens 0–255 are the raw bytes. Every merge adds one new token on top.

Tokenization is then fixed

Once the merges are learned, any new text is split by replaying them in the same order. Try a word with the vocabulary learned up to the current step:

This page runs real Byte Pair Encoding on the UTF-8 bytes of the text above: in every step it counts all neighbouring pairs, takes the most frequent one (on a tie, the pair that appears first in the text) and replaces it with a new token. It stops when no pair appears twice, or after 80 merges. Real tokenizers do the same on a huge body of text until the vocabulary has roughly 100,000 to 200,000 tokens. To see how a real model splits your text, try Tiktokenizer.

AI transparency

This demo is a scripted, self-contained browser simulation. Nothing you type is sent to an AI model and no live AI system runs behind it, even where it plays one. Its code and copy were built with generative AI (Anthropic’s Claude) and reviewed by Robert Barcik, who is responsible for what is published (LearningDoe s.r.o.). Disclosed in the spirit of Article 50 of the EU AI Act.