MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT-LLM / get_tokenizer

Function get_tokenizer

tensorrt_llm/serve/scripts/backend_request_func.py:417–432  ·  view source on GitHub ↗
(
    pretrained_model_name_or_path: str,
    tokenizer_mode: str = "auto",
    trust_remote_code: bool = False,
    **kwargs,
)

Source from the content-addressed store, hash-verified

415
416
417def get_tokenizer(
418 pretrained_model_name_or_path: str,
419 tokenizer_mode: str = "auto",
420 trust_remote_code: bool = False,
421 **kwargs,
422) -> Union[PreTrainedTokenizer, PreTrainedTokenizerFast]:
423 if tokenizer_mode == "slow":
424 if kwargs.get("use_fast", False):
425 raise ValueError(
426 "Cannot use the fast tokenizer in slow tokenizer mode.")
427 kwargs["use_fast"] = False
428 return AutoTokenizer.from_pretrained(
429 pretrained_model_name_or_path,
430 trust_remote_code=trust_remote_code,
431 **kwargs,
432 )
433
434
435ASYNC_REQUEST_FUNCS = {

Callers 1

mainFunction · 0.90

Calls 2

getMethod · 0.45
from_pretrainedMethod · 0.45

Tested by

no test coverage detected