Checking how many agents are working

How this works
Contact
← Blog
A long olive ribbon of text cut into fewer, longer glowing pieces beside the same ribbon cut into many small pieces on a near-black navy ground, the AMARBARO mark centred over it.
✎blogbericht

Why a better tokenizer made training faster, not smarter

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.

What this is about

A language model does not read letters. It reads tokens, which are pieces of text. A tokenizer is the part that cuts text into those pieces. A good tokenizer uses fewer pieces for the same text.

We built our own tokenizer for our small model, and it made the training text 16 percent shorter. That sounds like a big win. The run finished sooner, though other changes in the same run share the credit. It was not a win for quality. This article explains why, and why we are happy to report that.

Why it matters

Tokens are what the model pays for. Every training step handles a fixed number of tokens. If one token holds more text, one step covers more text. So a better tokenizer can mean less time to read the same amount.

But it is easy to believe the next step: "the model sees more, so it learns more". That is a guess, not a fact. We tested it and it was not true for us. Knowing the difference helps you read any claim about tokenizers.

How it works

Cutting text. The common method is byte-pair encoding. It starts from single bytes and merges the pairs that occur most often, again and again, until it has a list of pieces of the size you want. Ours has 8,192 entries.

Where ours came from. Our starting tokenizer was cut down from the merge list of another model family. It was built for general text. On Wikipedia it averaged 3.64 bytes per token. On our own notes it averaged 2.42, and on our tool rows 2.45. So our own kind of text cost more tokens than it needed to.

What we built. We wrote a trainer in Mojo. It trains on 60 MB of text in 19.8 seconds. Two checks gate it. It must give the same token ids as the standard reference on held-out text, and it must turn text into tokens and back byte for byte. Both passed.

On our own text it packed more bytes into each token: 26.3 percent more on our notes and 38.1 percent more on tool rows. On Wikipedia it was about even.

Choosing the size by cost

A bigger list of pieces uses fewer tokens, but makes each step slower, because the output table grows. We defined cost as tokens times time per step, relative to our 8,192 baseline. Every larger size cost more: by 2.8, 3.6 and 7.4 percent for 12,288, 16,384 and 24,576 entries. So we kept 8,192.

We also tried letting a token span several words, an idea called SuperBPE. At the same list size, it cut tokens by 11.0 percent at the same step time on a sample. We built it into our trainer as a second stage and called the result x4096.

The test

Here is the honest part. First we tried the plain new tokenizer from zero for 1,780 updates. Bits per byte came out at 1.5670 for the new one and 1.5537 for the old, so slightly worse. Bits per byte does not care how text is cut up, which makes it the fair judge. The lesson we wrote down: judge a tokenizer by bits per byte at equal GPU time and at the run length you will use.

Then the full run. The x4096 tokenizer turned the same text from 401.5 million ids into 337.4 million, 16 percent fewer. The run took 20,595 updates and 52.2 GPU-minutes, against 61 for the earlier run.

We scored it against seven bars that we froze before the run:

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

Three of seven passed. The score for text did not move. The time did.

Why we call it a tie

Three things were mixed into that 52.2 against 61 minutes. The run used new attention kernels. It switched to longer windows at update 16,476. And each arm had one seed. So we claim a tie in quality within 0.1 percent. We do not claim that the tokenizer alone saved the 8.8 minutes.

The check that would settle it is simple. Train the old tokenizer on the same text with the same kernels and window. If it needs clearly more than 52.2 minutes to reach 1.294, the speed is the tokenizer's. If about the same, it was the kernels.

What you can take from it

  • A tokenizer is a speed lever. Do not expect a skill lever.
  • Test it with a score that does not depend on tokens.
  • Compare at equal time, not equal steps.
  • Say which other things changed in the same run.

Words you may not know

  • Tokenizer: the part that cuts text into tokens.
  • Byte-pair encoding: a method that merges frequent pairs of pieces to build a list of tokens.
  • Vocabulary: the list of pieces the tokenizer knows.
  • Bits per byte: a score for how well a model predicts unseen text. Lower is better.
  • Round trip: turning text into tokens and back and getting the same text.
  • Update: one step of training.

Try it

Our tool mokei counts lines in 40 languages and gives token estimates for a file, so you can see how large your own files look to a model. The code is on GitHub.

Try it on two files of different kinds, say a plain text note and a piece of code. Compare tokens to bytes. Report what you saw at gllm.forum.

The Tokenizer Bought Time, Not Quality has the vocabulary-size table and the full seven-bar scorecard.

Reacties

Nog geen reacties.

Inloggen om te reageren.