MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / encode

Method encode

llama_cpp/llama_tokenizer.py:62–67  ·  view source on GitHub ↗
(
        self, text: str, add_bos: bool = True, special: bool = True
    )

Source from the content-addressed store, hash-verified

60 return self._model.detokenize(tokens, special=special)
61
62 def encode(
63 self, text: str, add_bos: bool = True, special: bool = True
64 ) -> List[int]:
65 return self.tokenize(
66 text.encode("utf-8", errors="ignore"), add_bos=add_bos, special=special
67 )
68
69 def decode(self, tokens: List[int]) -> str:
70 return self.detokenize(tokens).decode("utf-8", errors="ignore")

Callers 2

tokenizeMethod · 0.45
detokenizeMethod · 0.45

Calls 1

tokenizeMethod · 0.95

Tested by

no test coverage detected