MCPcopy Create free account
hub / github.com/BerriAI/litellm / encode_to_numpy

Method encode_to_numpy

litellm/litellm_core_utils/tokenizer.py:97–109  ·  view source on GitHub ↗
(
        self,
        text: str,
        *,
        allowed_special: AllowedSpecial = frozenset(),
        disallowed_special: SpecialTokens = "all",
    )

Source from the content-addressed store, hash-verified

95 return self._native.encode_special(text, tuple(allowed))
96
97 def encode_to_numpy(
98 self,
99 text: str,
100 *,
101 allowed_special: AllowedSpecial = frozenset(),
102 disallowed_special: SpecialTokens = "all",
103 ) -> npt.NDArray[np.uint32]:
104 import numpy
105
106 return numpy.asarray(
107 self.encode(text, allowed_special=allowed_special, disallowed_special=disallowed_special),
108 dtype=numpy.uint32,
109 )
110
111 def encode_ordinary_batch(
112 self, text: Sequence[str], *, num_threads: int = 8

Calls 1

encodeMethod · 0.95