Urgent.News

What's breaking now, across thousands of outlets.

Tech

BERT's tokenizer bottleneck was hiding before WordPiece

BERT's tokenizer bottleneck was hiding before WordPiece Normalization consumed 88% of a warm English encoding pass with bert-base-uncased . WordPiece, the algorithm that chooses tokens, took 8%. Simon Brandeis reports those measurements in his October 15 Hugging Face article , which follows the work from a CPU profile to a proposed implementation. The surprising part is where the time went. A…

BERT's tokenizer bottleneck had been overlooked until the introduction of WordPiece normalization, which accounted for 88% of a warm English encoding pass in the bert-base-uncased model. The bottleneck lay in the WordPiece token selection algorithm, taking up only 8% of the time. Simon Brandeis detailed these findings in an October 15 Hugging Face article following CPU profiling and proposing an implementation.

The surprising revelation was the actual time spent by the tokenizer - not in finding token boundaries, but in preparing characters.

A tokenizer often appears to be a problem of identifying token boundaries, but the profile showed the cost was primarily in character preparation. This made tokenization worthy of separate measurement from the model in embedding or RAG services. However, it didn't establish tokenization as a dominant factor in any specific service.

The normalizer performed the same expensive work for regular characters, cleaning text, inserting spaces around Chinese characters, decomposing Unicode characters, stripping accents, and lowercasing the result.

The profiling exposed a costly check for nonspacing marks used by the normalizer to remove accents. It conducted Unicode property lookups even for ASCII letters that didn't require decomposition or accent removal. The profile highlighted repeated work on common cases rather than expensive rare inputs. The letter 's', for instance, went through a general Unicode path, decoding it, looking up its properties, and passing it through normalization.

Yet, its UTF-8 byte could immediately tell the implementation it was ASCII, allowing a cheaper path without altering its output.

The proposed branch introduced vector instructions to inspect 16 bytes at once, identifying UTF-8 bytes with a clear high bit to skip unnecessary Unicode normalization for ASCII. This shortcut benefited English and source code most in the reported corpora, while other scripts required different shortcuts based on script tendencies and nearby characters.

The implementation first checked if it could leave text alone, then avoided paying for unnecessary transformations. The branch achieved up to another 5.7 times faster BERT encoding, totaling around 50 times compared to tokenizers' 0.23 baseline.

These changes were still in a pull request when Brandeis published the findings. The speedup was measured in isolation, not as part of a complete RAG request, GPU inference, or application latency. The experiment's results showed that Chinese barely benefited, and some tiny inputs became slower. However, these findings offered a significant reason to examine normalization when tokenization appeared expensive, particularly for BERT-style embedding pipelines.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Connected steps are not a workflow

Take a task that crosses two apps. A customer asks for a refund. The request lives in the support desk. The order lives in the billing system.

  • Refund request exists in support desk, order in billing system
  • Refunds over $50 require manager approval, not defined in API
  • No confirmation of refund processing before customer note sent

Zero-Latency Motion Tracking with OpenCV

Heavy machine learning models don't work everywhere, especially not on the edge where computing power is not as good. I have recently developed a simple and fast working procedure to achieve motion…

More from Friday 16 October →