Checking how many agents are working

How this works
Contact
← Blog
Long olive light lines converging on a single bright cut, with fewer, shorter segments around it.
✎blogbericht

The Tokenizer Bought Time, Not Quality

The short version

Our Mojo-trained tokenizer cut the same training text by 16 percent and bought GPU time (52.2 minutes against 61) but not quality: bits per byte landed 0.1 percent above the bar in one run.

Part 4 of 9 in Training Metis. Previous: 400 Million Tokens for 73 Million Parameters · Next: Measure the Kernel Before the Idea

Our own tokenizer made the training text 16 percent shorter, and the model learned no better for it. On held-out text it needed 1.2951 bits per byte, against a bar of 1.294. That is a miss of 0.1 percent. The run did finish sooner: 52.2 GPU-minutes instead of 61. Our reading is that a tokenizer is a speed lever for us and not a learning lever, with one caveat: new flash attention kernels were in the same run (see the end).

Metis is the small language model we train at home on one AMD 7900 XTX. It has 72,632,320 weights and its job is to call four tools: calc, brain_ask, web_fetch and run_js. This part is about the piece that sits in front of the model, the tokenizer, and what it was worth.

A tokenizer sets how much text one step can see

A tokenizer cuts text into tokens, the pieces the model actually reads. The model pays per token, not per byte. A tokenizer that packs more bytes into each token lets one training step, and one context window, hold more text.

Our starting tokenizer had 8,192 entries, cut down from the merge list of Qwen3. On Wikipedia it averaged 3.64 bytes per token. On our own Brain notes it averaged 2.42, and on our tool rows 2.45. It came from the Qwen3 merge list, not from our text.

We wrote the trainer in Mojo and checked it against the standard one

We built a byte-pair-encoding trainer in Mojo. It trains on 60 MB of text in 19.8 seconds. Two checks gate it. It must produce the same token ids as the HuggingFace reference on held-out text, and it must round-trip text byte for byte on six held-out tails. Both passed.

On our own text the gain was large, compared with the old tokenizer, in bytes per token:

text change in bytes per token
Wikipedia -0.2%
our Brain notes +26.3%
GSM8K math rows +28.3%
tool rows +38.1%

The table is for a tokenizer trained on a sample that was 70 percent Wikipedia. A variant trained on the full mix reached +42.3 percent on notes and +41.6 percent on tool rows, with Wikipedia at -3.7 percent. More of a tool row fits in the window.

The catch was our big corpus. The 400-million-token round was mostly Wikipedia-style text (about 82 percent). There an own 8,192 tokenizer trained on an 86-percent-Wikipedia sample saved only 3.0 percent of the tokens (388.8M against 400.9M). A 16,384-entry vocabulary saved 11.9 percent, but the output table grows by 8.4 million weights on a 72.6 million model, and we estimated the step to be about 11 percent slower. We did not measure that last number. We called it about even.

We picked 8,192 entries by cost, not by size

We defined cost as tokens times milliseconds per update, both relative to our 8,192 baseline. A bigger vocabulary saves tokens, but every step gets slower because the output layer grows.

vocabulary tokens step time cost
12,288 0.949 1.084 1.028
16,384 0.918 1.129 1.036
24,576 0.883 1.217 1.074

Every larger size cost more, by 2.8, 3.6 and 7.4 percent. Step time was noisy. One process start picked its own speed: the 24,576 size read 183 ms and 217 ms at equal clocks. So each size got 8 interleaved process starts.

Four smaller decisions came out of the same test. The sample should be 70 percent Wikipedia. Going from 95 to 70 percent costs 0.9 percent of the corpus tokens and buys 3.9 percent on our own text, while going from 70 to 50 percent costs 1.7 percent for 2.0. We kept the Qwen splitter, which cuts numbers into single digits, because we wanted the model to copy numbers digit by digit. That was a judgment from a paper, not a measurement of ours. We rejected a unigram tokenizer: 1.5 percent fewer tokens, 24 percent worse on Brain notes, and no byte-exact round trip. And we put no normalizer in the file, because llama.cpp and our own server never normalize text, and a normalizer would disagree with all three on 10 lines of our code.

The tokenizer passed all 7 of its gates. Those gates measured held-out text only. At that point no model had been trained on it, so we made no quality claim.

Fewer tokens did not mean faster learning

The first training test said no. We took the new 8,192 tokenizer, which made the same 419 MB of text 6.9 percent shorter, and trained from zero for 1,780 updates on two seeds against the old one. Bits per byte, where lower is better, came out at 1.5670 for the new tokenizer and 1.5537 for the old. The new one was slightly worse, within twice the spread between seeds.

Bits per byte counts the bits needed per byte of text, so it does not care how the text is cut into tokens. That makes it the fair judge. The lesson we wrote down: judge a tokenizer by bits per byte at equal GPU time, at the run length you will use.

Across spaces: 11 percent fewer tokens at the same step time

Ordinary byte-pair encoding never merges across a space, so a token is at most one word. The variant called SuperBPE lets a token span several words. On a 20 MB sample it cut tokens by 11.0 percent at the same vocabulary size and the same step time. When we first tried it, we did not know if it would hold at our size. The published SuperBPE results measured 8-billion-weight models with a 200,000-entry vocabulary. Ours has 73 million weights and 8,192 entries.

We added a second training stage to the Mojo trainer that merges across spaces, starting from 4,096 ordinary entries. We named the result x4096. On our text it made 14.0 percent fewer ids than the plain 8,192 tokenizer above (tokv3).

The run: 16 percent fewer tokens, quality within 0.1 percent

We re-encoded the same text. The 400M round had 401.5 million ids. The new one had 337.4 million, 16 percent fewer. The run took 20,595 updates in 11 chunks of about 300 seconds, 52.2 GPU-minutes in all, against 61 for the earlier run. Same 72.6 million weights, same text.

We scored it against seven bars. The bars were the 400M round's own results, plus two checks that the chat template and the update time held.

check bar x4096 result
bits per byte 1.294 1.2951, miss by 0.1%
tool test (of 56 prompts) 55 50, miss
ARC-E (science questions) 0.322 0.315, miss
PIQA (physical commonsense) 0.547 0.542, miss
LAMBADA (last-word guessing) 0.099 0.108, pass
chat template parity must hold holds
update time under 61 minutes 52.2 minutes, pass

Three of seven passed. Do not set that against the "5 of 6 gates" of the 400M round: each round had its own preregistered list of bars, and we froze each before running.

Metis x4096 round, day report, interactive Open full page ↗

The tool test fell from 55 to 50. We cannot tell from one run whether the tokenizer did that. One new failure appeared in the same run: a single message with 223 repeated tool calls. Part 6 is about it.

What we did not show

Three things are mixed into that 52.2 against 61. The run used new flash attention kernels, which part 5 covers. It switched to 4,096-token windows at update 16,476. And each arm is one seed. Time per update is not stable even inside a run: it fell from 163 to 143 ms across chunks 1 to 4 with no change we made, which we put down to warm-up.

So we claim a tie in quality within 0.1 percent, not a win, and we do not claim that the tokenizer alone saved the 8.8 minutes. The check that would settle it is cheap to state: train the old tokenizer on the same text with the same kernels and window. If it reaches 1.294 in clearly more than 52.2 GPU-minutes, the speed is the tokenizer's. If it takes about the same, it was the kernels.

Reacties

Nog geen reacties.

Inloggen om te reageren.