AI Grounds

Open AI Grounds on a desktop

These interactive lessons need a larger screen. Please continue on a desktop or laptop computer.

Guided discovery

Byte Pair Encoding Lab

Count neighbors. Learn a merge. Test another word.

A token is one symbol or learned piece. This is character-based, within-word BPE. The fixed alphabet has a–z, = and </w>: 28 symbols, covering every example. </w> is one word-end symbol. Whitespace separates words and is not encoded. This is not a byte-level or production tokenizer.

Your training text

Repeated stems and suffixes make the merge choices easy to see. Each repeated word occurrence contributes to frequency.

low lower lowest
new newer low

Select a prefix of the learned rules, from 0 through 8. Exact edits commit with Enter or on blur. Inspection text never trains new rules. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.

Highest-frequency next pairs

Counts of adjacent symbol pairs across current training words, including repeated occurrences.
PairCountFrequency status
l + o4Tied maximum
o + w4Tied maximum

Ties use a fixed preset preference, then code-unit order as a fallback. Frequency alone does not pick a unique winner. These counts come from training, not the inspection words.

Last training replacement

No rule applied yet. Training words begin as characters plus one </w> each.

Inspection: lowest newer

Apply the same ordered rules to these words. Learned pieces have a pale fill; each outlined piece counts as one token.

lowest
lowest</w>
newer
newer</w>

Inspection tokens

Number of current inspection pieces, including word-end symbols.

13

7 + 6 = 13

At 0 merges: 13. 0% fewer tokens.

Vocabulary symbols

Fixed base symbols plus unique learned pieces; original symbols remain available.

28

28 + 0 = 28

Token count is not a measurement of bytes, memory use or semantic understanding.

Compare original examples

Apply the current rules without retraining. New whole words can still use known base characters; learned pieces need not have linguistic meaning.

All original comparison strings, with exact before/after token counts including end symbols.
TextCurrent piecesTokens at 0 → nowReduction
lowest newer
lowest</w>newer</w>
13 → 130%
glow tower
glow</w>tower</w>
11 → 110%
xyz
xyz</w>
4 → 40%
All pair frequencies and learned rules
Counts of adjacent symbol pairs across current training words, including repeated occurrences.
PairCountFrequency status
l + o4Tied maximum
o + w4Tied maximum
w + </w>3Below maximum
w + e3Below maximum
e + r2Below maximum
e + w2Below maximum
n + e2Below maximum
r + </w>2Below maximum
e + s1Below maximum
s + t1Below maximum
t + </w>1Below maximum

Only already-applied rules appear below; future selections are not shown. Preset preferences break ties only among maximum-frequency pairs.

StepLearned ruleFrequency before merge
Counts across merge prefixes

Both quantities use counts, with no independent rescaling. For these preset corpora every rule adds a distinct vocabulary symbol, but some inspection counts stay unchanged.

Merge prefixInspection tokensVocabulary symbols
0 · Current1328
11229
21130
31031
4932
5833
6834
7735
8736

The alphabet covers the listed lowercase examples and =; arbitrary Unicode or unknown characters are outside this lab. Fewer tokens do not guarantee a better model, smaller stored vocabulary or lower total memory cost.

Repetition, 0 merges. Inspection 13 tokens; vocabulary 28 symbols. No rule applied.