MCPcopy
hub / github.com/openai/tiktoken / decode_tokens_bytes

Method decode_tokens_bytes

tiktoken/core.py:303–310  ·  view source on GitHub ↗

Decodes a list of tokens into a list of bytes. Useful for visualising tokenisation. >>> enc.decode_tokens_bytes([31373, 995]) [b'hello', b' world']

(self, tokens: Sequence[int])

Source from the content-addressed store, hash-verified

301 return self._core_bpe.decode_single_token_bytes(token)
302
303 def decode_tokens_bytes(self, tokens: Sequence[int]) -> list[bytes]:
304 """Decodes a list of tokens into a list of bytes.
305
306 Useful for visualising tokenisation.
307 >>> enc.decode_tokens_bytes([31373, 995])
308 [b'hello', b' world']
309 """
310 return [self.decode_single_token_bytes(token) for token in tokens]
311
312 def decode_with_offsets(self, tokens: Sequence[int]) -> tuple[str, list[int]]:
313 """Decodes a list of tokens into a string and a list of offsets.

Callers 1

decode_with_offsetsMethod · 0.95

Calls 1

Tested by

no test coverage detected