Byte Pair Merge Desk encodes the same probe abc in two ways. Ranked replay of the learned rules returns token IDs [97, 256] with byte boundary cuts [0, 1, 3], the split a | bc. A longest-prefix encoder reading the same structured vocabulary returns [257, 99] with cuts [0, 2, 3], the split ab | c. Both paths have two tokens, and both reconstruct the original bytes 616263. The IDs differ, and the cuts differ. The cuts are this inspector's own output fields; no model is run and no boundary array is handed to one. A token count of two hides two different ID sequences and two different byte splits.

Two splits for abc

This tool's profile operates on raw bytes. Its base vocabulary has 256 IDs, one for each byte value, even when the corpus never uses some of those bytes. Learning repeatedly counts adjacent token-ID pairs inside each record, including overlapping positions, selects the maximum count, breaks ties by smallest numeric left ID and then smallest right ID, and assigns a new ID equal to 256 plus the zero-based learned rank. Replacement is non-overlapping and moves from left to right.

The default corpus is four records: bc, bc, ab, abc. In hex that is 6263, 6263, 6162, 616263. The merge budget is two, and the probe is abc, hex 616263.

Round zero counts the pair (98, 99), the bytes bc, three times: once in each bc record and once inside abc. The pair (97, 98), the bytes ab, counts twice at this stage, once in the ab record and once inside abc. Three wins, so rank zero learns (98, 99) → 256. After replacement, the records are [256], [256], [97, 98], and [97, 256].

Round one counts the remaining sequences again. The ab record still contributes (97, 98) once. The record that was abc now contributes (97, 256), because its original (97, 98) adjacency was consumed by the bc merge. So (97, 98) and (97, 256) each have count one; the earlier count of two for ab does not survive past the bc merge. Both candidate left IDs are 97, and the tie rule picks the smaller right ID, 98, so rank one learns (97, 98) → 257.

Encoding the probe [97, 98, 99] replays the rules in rank order. Rank zero applies first and rewrites the probe as [97, 256]. Rank one looks for (97, 98), but that pair no longer appears. The ranked result stays [97, 256], with cuts [0, 1, 3].

Two strategies over the same vocabulary

After two merges, this profile's full vocabulary keeps every learned token as a structured record. Each entry has its ID, hex spelling, byte length, and, for learned tokens, the parent IDs and the learned rank. The two learned rows here are ID 256 with hex 6263, parents (98, 99), rank 0, and ID 257 with hex 6162, parents (97, 98), rank 1. Even on their own, the 256-plus-rank ID numbering preserves the rank order.

The greedy comparison chooses not to read those rank and parent fields. Its cursor starts at probe byte zero, and at each position it searches the vocabulary for the longest hex spelling that matches the remaining probe, with equal lengths resolved by the smallest numeric ID. At byte zero of abc, the vocabulary spellings include a with length one and ab with length two. The longest match is ID 257, covering bytes [0, 2). The remaining byte [2, 3) matches c, ID 99. The greedy output is [257, 99], with cuts [0, 2, 3].

This is the useful distinction. Ranked replay uses the learned order: rank zero changed the probe before rank one was tested, so (97, 98) is tried but finds no match. Longest-prefix matching ignores that order even though the vocabulary stores it. bc has a vocabulary row, but it does not match at byte zero, so it never gets a chance to influence this probe. The two strategies produce different IDs and different cuts from the very same learned data. When I debug a tokenizer or compare a checkpoint with a reference implementation, the difference tells me whether the encoder actually followed the learned sequence or picked matches by a simpler view of the same table.

Overlapping candidates

The second named case is one record of five a bytes, hex 6161616161, with a one-merge budget and the same five bytes as probe. Round zero counts (97, 97), the bytes aa, at four adjacent positions: 0 and 1, 1 and 2, 2 and 3, 3 and 4. Pair counting includes overlaps, so the chosen frequency is 4.

Replacement is non-overlapping from the left. The pass combines positions 0 and 1, then 2 and 3, and leaves the fifth a alone. That is two actual replacements and a token reduction of two. The report keeps all three numbers: chosen frequency 4, actual replacements 2, token reduction 2. The 4 is a counting result, not the round's savings; treating it as savings would overstate the reduction by two tokens.

This five-byte single-round aaaaa request is separate from the repeated-byte case in the original figure, which uses a two-merge budget and the four-byte probe 61616161.

What the report keeps

Every learned round keeps the full pair inventory sorted by left ID and right ID, the winning count, all tied best pairs, the parent IDs, the new ID, and the before and after state of each record with exact source-byte spans. The probe section keeps the ranked replay history, including rules that were tried and found no match, plus every greedy step with all matching candidates and tie IDs. Raw hex, token IDs, and source-byte spans are the authoritative fields. Selecting a round or changing a page only changes the on-screen table; it does not truncate exports.

The downloaded JSON is the complete nested report, including the full request and all source data with byte spans. The three CSV files are complete projections. The pairs CSV carries rank, left and right pair IDs, count, and the chosen/tied flags. The merges CSV carries the per-round merge fields. The probe CSV carries algorithm, index, ID, start, end, and hex for both probe algorithms; its hex rows can rebuild the probe byte sequence, but it has no corpus records and no request block. Exports are not an anonymization step. The JSON at least exposes the input, and the other files expose their declared columns, so I check what a file actually contains before sharing it.

The original figure

The image below is the fixed source-data figure for the four predeclared cases. It shows ranked and greedy IDs, exact boundary cuts, per-round candidate counts, and actual replacement counts, including cases where the two algorithms agree. The first four entries of examples.json at the same commit contain those case requests.

Byte Pair Merge Desk original figure, 1120 by 1040, showing four predeclared byte-BPE cases with ranked and longest-prefix IDs, byte cuts, candidate counts, and actual replacements per learned round

Teaching boundaries

This profile operates on raw bytes only. It does no Unicode normalization, no text pre-tokenization, no inserted separator, and no unknown-token fallback. A byte is not a Unicode character, and byte length is not visible character count. The base vocabulary includes all 256 one-byte tokens, even the bytes the corpus never uses. Records never merge across boundaries. A repeated record counts again, and an empty record remains part of the source identity and full record states. The probe never contributes to learning.

The caps are 1 to 16 records, 0 to 128 bytes per record, 512 bytes total, 256 bytes for the probe, and 0 to 32 learned merges. Duplicate byte spellings keep distinct IDs by contract. The fixed 58-case fixture bank did not observe such a duplicate, and that absence is recorded as an observation, not a theorem.

The corpus digest input is the canonical JSON of lowercase corpus_hex. That serialization includes record layout, order, repeats, and empty records. The SHA-256 digest over that serialization is a noninvertible consistency fingerprint, useful for comparing source layouts. It is not authentication and not tamper protection.

Input stays in browser memory and is not uploaded. Clear removes the current UI state and disables exports, which is not a secure erase. The CLI checks the input path with lstat and requires a regular nonsymlink input file. Output opens with the exclusive wx flag, so an existing output path or symlink is refused. These are bounded file guards, not race-free filesystem isolation.

The current app is available at the formal Byte Pair Merge Desk Space and as a standalone static page.

Checking the two cases locally

The fixed commit contains reference.py, an independent Python implementation that models byte intervals with maps instead of mutating integer-ID arrays, and shares no production import. To repeat the two observations, download reference.py at fixed commit 00453fa2 into the current directory, then run:

python3 - <<'PY' from reference import report, DEFAULT r = report(DEFAULT) for name in ('ranked_probe', 'greedy_probe'): p = r[name] print(name, 'ids=', p['token_ids'], 'cuts=', p['boundary_cuts'], 'reconstructs=', p['byte_reconstruction_matches']) r2 = report(dict(corpus_hex=['6161616161'], merge_budget=1, probe_hex='6161616161')) m = r2['training_rounds'][0] print('aaaaa round0', 'chosen_frequency=', m['chosen_frequency'], 'actual_replacements=', m['actual_replacements'], 'token_reduction=', m['token_reduction']) PY 

This script prints three stdout lines. The two loop lines are the ranked and greedy results for the default abc case: ranked IDs [97, 256] with cuts [0, 1, 3], greedy IDs [257, 99] with cuts [0, 2, 3], and both reconstruct the probe. The final line is the one-round five-byte aaaaa case: chosen frequency 4, actual replacements 2, token reduction 2. The snippet checks only these two synthetic inputs. It is not a model run and does not replace the project's recorded checks.

License and contract: Apache-2.0 LICENSE, PROTOCOL.md, MATH.md.

English original: Two tokens can hide two different byte splits in a byte-level BPE.