The hugging face 'tokenizers' library explicitly notes its high performance — to...
Brad Larsen @bradlarsen@infosec.exchange
The hugging face 'tokenizers' library explicitly notes its high performance — tokenizing text at over over 50MB/s on a server-class CPU!
Now, I'm not familiar enough with the algorithms involved to say if 50MB/s is something to brag about, or something to be embarrassed about.
However, I've been looking at its Rust implementation though, and it does not seem especially performance-oriented.
For example, when you tokenize an input string using the 'Tokenizer::encode' method, at least 7 vectors and a hashtable are allocated, with no way to provide pre-allocated data.
Another example: the 'batch_encode' method parses an environment variable each time it is called.
In a common use case (ML inference), your program will be calling this tokenization code in a loop with fixed-size batches of inputs. It seems as though there is some performance left on the table.