MCPcopy Index your code
hub / github.com/abetlen/llama-cpp-python / tokenize

Method tokenize

llama_cpp/llama.py:595–611  ·  view source on GitHub ↗

Tokenize a string. Args: text: The utf-8 encoded string to tokenize. add_bos: Whether to add a beginning of sequence token. special: Whether to tokenize special tokens. Raises: RuntimeError: If the tokenization failed. Return

(
        self, text: bytes, add_bos: bool = True, special: bool = False
    )

Source from the content-addressed store, hash-verified

593 )
594
595 def tokenize(
596 self, text: bytes, add_bos: bool = True, special: bool = False
597 ) -> List[int]:
598 """Tokenize a string.
599
600 Args:
601 text: The utf-8 encoded string to tokenize.
602 add_bos: Whether to add a beginning of sequence token.
603 special: Whether to tokenize special tokens.
604
605 Raises:
606 RuntimeError: If the tokenization failed.
607
608 Returns:
609 A list of tokens.
610 """
611 return self.tokenizer_.tokenize(text, add_bos, special)
612
613 def detokenize(
614 self,

Calls

no outgoing calls