Closed LNTH closed 3 weeks ago
Hi @LNTH,
Yes, this is expected behaviour. OpenVINO Tokenizers contains two parts: 1) Binary OpenVINO extension that contains an implementation of tokenization operations 2) Python code that does the tokenizer conversion
To use the model with tokenizer operation, you must extend a Core
object with the binary extension. There are several ways to do that:
1) The easiest (and recommended) way is to import openvino_tokenizer
before you create a Core
object. It will patch the Core
object constructor to add the binary extension automatically. See the example from the readme. It is recommended to use a minimal installation option in the production to reduce the environment size.
2) Add extension manually: core.add_extension("path/to/libopenvino_tokenizers.so")
. This path is primarily for C++ usage, but is also applicable if you use OpenVINO Python distribution from an archive.
To get a path to the binary extension in case of Python installation, you can use this command:
python -c "from openvino_tokenizers import _ext_path; print(_ext_path)"
I hope this helps. If you have any further questions, please let me know.
Thanks @apaniukov, that’s all I need to know about ov-tokenizers.
I have one more question: what is the roadmap for implementing a detokenizer for WordPiece? For example, in an NER use case using small variant of BERT (tinybert, mobilebert, distilbert), which all utilizes WordPiece, without a detokenizer, I still have to rely on the transformers tokenizer for mapping token labels back to word labels.
Yes, we plan to cover all subword tokenizer/detokenizer types, including WordPiece detokenizer. For the NER use case, adding the output with token offsets in the original string is useful. It is on our roadmap, but other tasks have a higher priority right now.
Context
I successfully converted the tokenizer into an OpenVINO (OV) model and connected it with my main model. However, when I use the combined model, I still need to import openvino_tokenizers.
Code to reproduce
Environment: Google Colab
Code to convert model
Use the combine_model (after restart session)
Error
Question:
Is this behavior expected? Or is there a way to avoid including the OpenVINO tokenizer in my production environment?