Hugging Face engineers make BERT tokenization 50x faster by skipping ASCII

art_zucker · x · 2026-10-15

Hugging Face engineer Simon Brandeis details how the team made BERT-like model tokenization up to 5.7x faster on top of the tokenizers library overhaul — roughly 50x faster than v0.23 in total (changes still in PR stage).

Context

Why BERT matters

BERT-like encoders power embeddings, search, RAG, rerankers, and classifiers. The three most-downloaded models on the Hub (all-MiniLM-L6-v2 at 218M monthly downloads, ms-marco-MiniLM-L6-v2 at 79M, bge-small-en-v1.5 at 59M) all use BERT's normalizer; across the top 10,000 models, WordPiece accounts for 627M monthly downloads.

Key technique

As the title hints, skipping ASCII-related processing in BERT's normalizer was the key to the extra 5.7x speedup, alongside other engineering optimizations.

Related event: Hugging Face's tokenizers v1 push makes BERT tokenizer ~50x faster(6 posts)→

Original post →

More from Infra

Infra channel →