openvino_genai.Tokenizer#
- class openvino_genai.Tokenizer#
Bases:
pybind11_object
openvino_genai.Tokenizer object is used to initialize Tokenizer if it’s located in a different path than the main model.
- __init__(self: openvino_genai.py_openvino_genai.Tokenizer, tokenizer_path: os.PathLike, properties: dict[str, object] = {}) None #
Methods
__delattr__
(name, /)Implement delattr(self, name).
__dir__
()Default dir() implementation.
__eq__
(value, /)Return self==value.
__format__
(format_spec, /)Default object formatter.
__ge__
(value, /)Return self>=value.
__getattribute__
(name, /)Return getattr(self, name).
__gt__
(value, /)Return self>value.
__hash__
()Return hash(self).
__init__
(self, tokenizer_path[, properties])This method is called when a class is subclassed.
__le__
(value, /)Return self<=value.
__lt__
(value, /)Return self<value.
__ne__
(value, /)Return self!=value.
__new__
(**kwargs)Helper for pickle.
__reduce_ex__
(protocol, /)Helper for pickle.
__repr__
()Return repr(self).
__setattr__
(name, value, /)Implement setattr(self, name, value).
Size of object in memory, in bytes.
__str__
()Return str(self).
Abstract classes can override this to customize issubclass().
apply_chat_template
(self, history, ...[, ...])Embeds input prompts with special tags for a chat scenario.
decode
(*args, **kwargs)Overloaded function.
encode
(*args, **kwargs)Overloaded function.
get_bos_token
(self)get_bos_token_id
(self)get_eos_token
(self)get_eos_token_id
(self)get_pad_token
(self)get_pad_token_id
(self)set_chat_template
(self, chat_template)Override a chat_template read from tokenizer_config.json.
- __class__#
alias of
pybind11_type
- __delattr__(name, /)#
Implement delattr(self, name).
- __dir__()#
Default dir() implementation.
- __eq__(value, /)#
Return self==value.
- __format__(format_spec, /)#
Default object formatter.
- __ge__(value, /)#
Return self>=value.
- __getattribute__(name, /)#
Return getattr(self, name).
- __gt__(value, /)#
Return self>value.
- __hash__()#
Return hash(self).
- __init__(self: openvino_genai.py_openvino_genai.Tokenizer, tokenizer_path: os.PathLike, properties: dict[str, object] = {}) None #
- __init_subclass__()#
This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
- __le__(value, /)#
Return self<=value.
- __lt__(value, /)#
Return self<value.
- __ne__(value, /)#
Return self!=value.
- __new__(**kwargs)#
- __reduce__()#
Helper for pickle.
- __reduce_ex__(protocol, /)#
Helper for pickle.
- __repr__()#
Return repr(self).
- __setattr__(name, value, /)#
Implement setattr(self, name, value).
- __sizeof__()#
Size of object in memory, in bytes.
- __str__()#
Return str(self).
- __subclasshook__()#
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- apply_chat_template(self: openvino_genai.py_openvino_genai.Tokenizer, history: list[dict[str, str]], add_generation_prompt: bool, chat_template: str = '') str #
Embeds input prompts with special tags for a chat scenario.
- decode(*args, **kwargs)#
Overloaded function.
decode(self: openvino_genai.py_openvino_genai.Tokenizer, tokens: list[int]) -> str
Decode a sequence into a string prompt.
decode(self: openvino_genai.py_openvino_genai.Tokenizer, tokens: openvino._pyopenvino.Tensor) -> list
Decode tensor into a list of string prompts.
decode(self: openvino_genai.py_openvino_genai.Tokenizer, tokens: list[list[int]]) -> list
Decode a batch of tokens into a list of string prompt.
- encode(*args, **kwargs)#
Overloaded function.
encode(self: openvino_genai.py_openvino_genai.Tokenizer, prompts: list[str], add_special_tokens: bool = True) -> openvino_genai.py_openvino_genai.TokenizedInputs
Encodes a list of prompts into tokenized inputs.
encode(self: openvino_genai.py_openvino_genai.Tokenizer, prompt: str, add_special_tokens: bool = True) -> openvino_genai.py_openvino_genai.TokenizedInputs
Encodes a single prompt into tokenized input.
- get_bos_token(self: openvino_genai.py_openvino_genai.Tokenizer) str #
- get_bos_token_id(self: openvino_genai.py_openvino_genai.Tokenizer) int #
- get_eos_token(self: openvino_genai.py_openvino_genai.Tokenizer) str #
- get_eos_token_id(self: openvino_genai.py_openvino_genai.Tokenizer) int #
- get_pad_token(self: openvino_genai.py_openvino_genai.Tokenizer) str #
- get_pad_token_id(self: openvino_genai.py_openvino_genai.Tokenizer) int #
- set_chat_template(self: openvino_genai.py_openvino_genai.Tokenizer, chat_template: str) None #
Override a chat_template read from tokenizer_config.json.