tokenizers v1: encode, decode and scaling, measured
Hugging Face
Hugging Face’s tokenizers v1 is getting a big speed boost, often by tens of times. It keeps the same token IDs as v0.23, so the gains come without changing outputs.
Based on reporting by Hugging Face — read the original for the full story.
Summary, retelling and take written by AI under human oversight; images are AI-generated illustrations. How we work · Report an error
Hugging Face is pushing a major rewrite of its tokenizers library, and the pitch is simple: stop making the CPU the thing that holds the GPU hostage. The new v1 release candidate keeps the same API, the same vocabulary, the same merge ranks, and the same token IDs as v0.23, but it is built to move a lot faster under real load.
The company says the work was driven by a basic shift in workload. Tokenization used to be the easy part. That changes when models get quicker, datasets get bigger, or a service has to chew through long inputs and many concurrent requests. In those cases, the tokenizer can become the slowdown, so v1 focuses hard on encode performance and on scaling across threads.
A lot of the win comes from removing general-purpose machinery where a tokenizer already knows exactly what it needs to do. BPE models had been using a regex-based split before the merge step; v1 replaces that with hand-written bitstream logic in the cases it supports. It also adds a thread-local word cache, so repeated pre-tokens can skip the merge work, and rewrites the merge loop to work from caller-owned scratch buffers instead of allocating fresh memory every time. The library also batches pre-tokens in a single model call and uses native parallelism so one tokenizer can encode from many threads at once.
The result, on the benchmarks Hugging Face ran with tokbench, is a lot of headroom. Across the ten model families it measured, v1 encoded text 3 to 30 times faster than v0.23 on one thread on an Apple M4 Max. The low end was t5-base, the high end gpt2. With eight workers, it scaled at 76% of linear. And throughout all of it, the output stayed exactly the same.
There’s still more coming. Hugging Face says the next priority is bringing more model families onto the new merge loop before 1.0.0, then pushing the gains into transformers and the rest of the ecosystem. For now, the release candidate is on crates.io, and the company is selling the most boring kind of upgrade: same call, same IDs, less waiting.
My take — AI-written commentary, not fact-checked reporting
This is the right kind of performance work: quiet, specific, and annoying to fake. Open-source ML tooling has spent too long celebrating benchmarks that only work in slides; this one at least tries to keep the IDs identical while shaving off the waste. Fancy names are optional, but fewer CPU naps are not.
Read more about this at: Hugging Face
Related stories
Meet Gigatoken: A Rust BPE Tokenizer that Encodes Text at 24.53 GB/s, up to 989x Faster than HuggingFace Tokenizers
MarkTechPost · 1 month ago ·
34
Optimizing inference speed and costs: Lessons learned from large-scale deployments
Together AI · 7 months ago ·
38
Capturing token IDs during agentic interactions for better reinforcement learning
Amazon Science · 2 months ago ·
34