An AI-powered entry in TopGit's GitHub warehouse: huggingface/tokenizers, 11.2k stars, AI Tools, Rust. π₯ Fast State-of-the-Art Tokenizers optimized for Research and Production
Snapshot summary built from the project's own GitHub metadata β there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then β see the READ ME tab for the original README in full.
The SOTA tokenization library on all languages, all models, all hardwares.
Our goal with tokenizers is to develop and maintain the industry's standard tokenization engine, making it the defacto place for everyone to contribute to the whole ecosystem.
Release candidate: v1.0.0.rc.x
As we are switching from 0.23 to v1.0.0, the current library does not ship all features. If you are worried, check the v1 features section for more details of what we are bringing back.
We will publish a blog about what breaking changes we introduced. We strived to keep them as small as possible.
Installation
pip install --pre tokenizers
For Rust, add the crate to your Cargo.toml:
[dependencies]
tokenizers = "1.0.0"
Training (train) and downloading from the Hub (http) are opt-in features. The crate's
Using the crate section lists every feature and how to
build a smaller binary.
Tokenizer holds the tokenizer.json config and can be edited (e.g. tokenizer.truncation = ...);
compile() builds the CompiledTokenizer that encodes and decodes.
Performances
For more details, checkout https://huggingface-tokenizers-v1.static.hf.space/index.html.
Bindings
status
Rust
β reference implementation
Python
β
Node.js
β
WebAssembly
β tokenizers-wasm on npm
C / C++ / Java / Go/ etc
π§ planned
Ruby
community, external repo
v1.0.0 roadmap:
As we work toward v1, we are gonna bring back the entire python API that allows transformers' style of interacting with a tokenizer object:
TODOS:
Python Bindings
Bring training back: this should be easy, but we want the perfs gains to come as well.
Batch encoding API with zero-copy views on encoded ids
dlpack API for torch / JAX / numpy interop.
Composition: edit components of the pipeline (tokenizer.normalizer = [...]). The editable
Tokenizer spec and compile() have landed; per-component handles are next.
tokenizer.save to persist a modified or trained tokenizer on disk.
role_to_token override.
Bring back offset output: this should be useful for people training.
Windowing / stride in encode.
Rust core
bitnorm: more performance from optimized normalization, as this will bring breaking changes we want to make sure it gets to v1.
Unroll more regex: we need to cover the most used ones, we might have missed one or two.
Other
C & C++ bindings for loading, encode and decode APIs
After 1.0.0
Improve / rewrite the bitcannon crate
Java, Go, Swift... bindings, supported by the C bindings
tk-devices β exploratory GPU encoding and batch decoding that keeps text and ids on the
device: upload the vocabulary once, compute output positions in parallel, gather the bytes on the
GPU. An optional component aimed at large batches, subject to prototyping and measurement.
Crate details
Crate size
Sub-crates
tk-encode β the inference engine
The models (BPE, Unigram, WordPiece, WordLevel) and the full pipeline: Normalizer,
PreTokenizer, Model, PostProcessor, Decoder.
Why separate: you don't need all features to serve a model in production settings. Splitting it from training
means a serving binary never links a trainer, a corpus reader, legacy converters, etc.
bitcannon β bitstream pre-tokenization
Unicode tag classification plus pre-tokenization as a bitstream program. Follows Interleaved Bitstream Execution for Multi-Pattern Regex Matching on GPUs
(MICRO'25, 10.1145/3725843.3756052) but we added our own algorithm to make sure we don't need a parabix engine.
Characters are first classified into "tags", which use a sparse table generated when compiling bitcannon. This means there are 0 depencencies to the heavy unicode tables.
Ships byte-exact grammars for gpt2 / ByteLevel, cl100k, o200k, tekken, deepseek and kimi-k2.
The classes or tags each have a high and low nibble (encoded on a u8), and carry refinement when needed. Using u8 tags allows us to leverage less bitsream, meaning have a simpler / faster pre tokenization.
Why separate: we just thought it might be useful to some people someday. As far as we know, this implementation is the fastest for every single pretokenizer regex on CPU.
tk-serialize β the reader
from_json_file turns a canonical tokenizer.json into a PipelineTokenizer.
Why separate: this just makes it optional for some usecases!
tk-convert β the upgrade pass
canonicalize_file rewrites legacy a tokenizer.json written by any older version of this library into
the canonical form the reader accepts. A pure JSONβJSON rewrite; it depends on nothing but
std::path and serde_json.
Why separate: every config ever published stays readable without the runtime carrying a decade
of compatibility branches. But, the legacy code amounted to quite a lot of the final crate size. Disabling it allows on device builds to be smaller.
tk-train β the training half
The Trainer trait, every concrete *Trainer, TrainerWrapper and the Trainable extension.
The tokenizers crate re-exports it behind the train feature, which is off by default. It
trains only the models whose feature is on (bpe, unigram, wordpiece, wordlevel). Add
esaxx_fast for the C++ suffix array behind Unigram training.
Why separate: training is a batch job on a workstation; inference is a hot loop in a server.
They have opposite constraints, so they get opposite dependency budgets.
bitmap_gen β dev-only table generator
cargo run -p bitmap_gen regenerates bitcannon's committed classify tables from unicode-properties, emitting one Atom tag per codepoint.
Why separate β this is what buys the zero Unicode dependency.unicode-properties is a
dependency of this crate and of nothing else: the tables it produces are checked into
bitcannon/src/classify/atom_tables.rs as ordinary source, so the Unicode data is resolved once, at
development time, by a crate that is never linked into anything that ships and is never published.
No build script either β bitcannon compiles with no code generation step, and a release binary
contains the tags without containing a Unicode crate to derive them. The release workflow re-runs
the generator and fails if the committed table differs, so "baked" cannot silently mean "stale".
tokenizers β umbrella
A thin re-export so existing tokenizers::β¦ paths keep working. Depend on this one unless you know
you want less.
Hardware
No SIMD is required. Every kernel has a portable path that is always compiled and is the
byte-exact test oracle for its vectorised siblings, so correctness never depends on a kernel being
present β only throughput does.
Which ops are hardware-adapted
op
aarch64
x86_64
wasm32
portable fallback
Unicode atom classify
NEON (baseline)
AVX-512 VBMI β SSE4.1/SSSE3, runtime-detected
SIMD128
classify_scalar
bitstream block build
NEON
SSE/AVX
β
build_block_scalar
literal & added-token scan
NEON
x86_64
β
scalar
vocab bucket nibble match
NEON
β
β
scalar
aarch64 selects at compile time (NEON is baseline). x86_64 dispatches at runtime via
is_x86_feature_detected!, so one binary covers every x86_64 CPU since 2008. wasm32 needs the
simd128 target feature; without it, the scalar walk.
Acknowledgements
This work stands on the shoulders of a lot of open source projects. Thanks to all of them for their great work.
gigatoken,
tiktoken, kitoken,
tokie, fastokens,
wordchipper and
ai-tokenizer each pushed on what a fast tokenizer can
be; we read that work, and several of the ideas above reached us because another project showed
they were worth trying.
How active is development on huggingface/tokenizers?
The most recent commit recorded on huggingface/tokenizers was 3 months ago, based on the GitHub push timestamp. The repository has 1.3k forks β one of the better signals of community interest.
Is huggingface/tokenizers open source?
Yes β huggingface/tokenizers ships under the Apache-2.0 license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/huggingface/tokenizers.
What license does huggingface/tokenizers use?
huggingface/tokenizers is released under the Apache-2.0 license. Always verify the LICENSE file directly on GitHub for the authoritative terms β license strings can be edited out of sync with a project's actual stance.
What topics is huggingface/tokenizers associated with?
GitHub's repository topics for huggingface/tokenizers: "bert", "gpt", "language-model", "natural-language-processing", "natural-language-understanding", "nlp", "transformers". TopGit's editorial category is AI Tools.
Where can I see huggingface/tokenizers in action?
The project maintains a homepage at https://huggingface.co/docs/tokenizers. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about huggingface/tokenizers?
This TopGit page is a snapshot β the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/huggingface/tokenizers is the definitive source.
Read full README in the tab above.
Still deciding about tokenizers?
One click hands the question to an AI along with this page β see what it says about tokenizers.