MCPcopy
hub / github.com/InternLM/lmdeploy / encode

Method encode

lmdeploy/tokenizer.py:367–371  ·  view source on GitHub ↗

Tokenize a prompt.

(self, s: str, add_bos: bool = True, add_special_tokens: bool = True, **kwargs)

Source from the content-addressed store, hash-verified

365 self.model._pad = __pad
366
367 def encode(self, s: str, add_bos: bool = True, add_special_tokens: bool = True, **kwargs):
368 """Tokenize a prompt."""
369 # ChtGLM4Tokenizer hardcode `add_speical_tokens=False` when tokenizing
370 # a prompt. Refer to https://huggingface.co/THUDM/glm-4-9b-chat/blob/main/tokenization_chatglm.py#L227 # noqa E501
371 return super().encode(s, add_bos, add_special_tokens=False, **kwargs)
372
373
374class ChatGLMTokenizer(HuggingFaceTokenizer):

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected