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

Method encode_batch

litellm/litellm_core_utils/tokenizer.py:117–127  ·  view source on GitHub ↗
(
        self,
        text: Sequence[str],
        *,
        num_threads: int = 8,
        allowed_special: AllowedSpecial = frozenset(),
        disallowed_special: SpecialTokens = "all",
    )

Source from the content-addressed store, hash-verified

115 return list(executor.map(self.encode_ordinary, text))
116
117 def encode_batch(
118 self,
119 text: Sequence[str],
120 *,
121 num_threads: int = 8,
122 allowed_special: AllowedSpecial = frozenset(),
123 disallowed_special: SpecialTokens = "all",
124 ) -> list[list[int]]: # mutable-ok: [LIT001] SDK return type
125 encode: Final = partial(self.encode, allowed_special=allowed_special, disallowed_special=disallowed_special)
126 with ThreadPoolExecutor(num_threads) as executor:
127 return list(executor.map(encode, text))
128
129 def encode_with_unstable(
130 self,

Calls 3

partialFunction · 0.85
listFunction · 0.50
mapMethod · 0.45