Live data from Hacker News

Show HN: HuggingFace – Fast tokenization library for deep-learning NLP pipelines

github.com

1–10 of 45 posts

Re: Show HN: HuggingFace – Fast tokenization library for deep-learning NLP pipelines

#3
TL;DR: Hugging Face, the NLP research company known for its transformers library (DISCLAIMER: I work at Hugging Face), has just released a new open-source library for ultra-fast & versatile tokenization for NLP neural net models (i.e. converting strings in model input tensors).

Main features: - Encode 1GB in 20sec - Provide BPE/Byte-Level-BPE/WordPiece/SentencePiece... - Compute exhaustive set of outputs (offset mappings, attention masks, special token masks...) - Written in Rust with bindings for Python and node.js

Github repository and doc: https://github.com/huggingface/tokenizers/tree/master/tokeni...

To install: - Rust: https://crates.io/crates/tokenizers - Python: pip install tokenizers - Node: npm install tokenizers

Re: Show HN: HuggingFace – Fast tokenization library for deep-learning NLP pipelines

#5
post #4

What does tokenization (of strings, I guess) do?

The README [1] shows a great example:

The sentence "Hello, y'all! How are you ?" is tokenized into words. Those words are then encoded into integers representative of the words' identity in the model's dictionary.

    >>> output = tokenizer.encode("Hello, y'all! How are you  ?")
    Encoding(num_tokens=13, attributes=[ids, type_ids, tokens, offsets, attention_mask, special_tokens_mask, overflowing, original_str, normalized_str])
    >>> print(output.ids, output.tokens, output.offsets)
    [101, 7592, 1010, 1061, 1005, 2035, 999, 2129, 2024, 2017, 100, 1029, 102]
    ['[CLS]', 'hello', ',', 'y', "'", 'all', '!', 'how', 'are', 'you', '[UNK]', '?', '[SEP]']
    [(0, 0), (0, 5), (5, 6), (7, 8), (8, 9), (9, 12), (12, 13), (14, 17), (18, 21), (22, 25), (26, 27), (28, 29), (0, 0)]
But there's also good detail in the source [2] which says, "A Tokenizer works as a pipeline, it processes some raw text as input and outputs an Encoding. The various steps of the pipeline are: ...."

[1] https://github.com/huggingface/tokenizers#quick-examples-usi...

[2] https://github.com/huggingface/tokenizers/tree/master/tokeni...

Re: Show HN: HuggingFace – Fast tokenization library for deep-learning NLP pipelines

#8
It used to be that pre-DeepLearning tokenizers would extract ngrams (n-token sized chunks) but this doesn't seem to exist anymore in the word embedding tokenizers I've come by.

Is this possible using HuggingFace (or another word embedding based library)?

I know that there are some simple heuristics like merging noun token sequences together to extract ngrams but they are too simplistic and very error prone.

Re: Show HN: HuggingFace – Fast tokenization library for deep-learning NLP pipelines

#10
I love the work done and made freely available by both spaCy and HuggingFace.

I had my own NLP libraries for about 20 years, simple ones were examples in my books, and more complex and not so understandable ones I sold as products and pulled in lots of consulting work with.

I have completely given up my own work developing NLP tools, and generally I use the Python bindings (via the Hy language (hylang) which is a Lisp that sits on top of Python) for spaCy, huggingface, TensorFlow, and Keras. I am retired now but my personal research is in hybrid symbolic and deep learning AI.

Post reply on HN