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

Method decode_single_token_bytes

tiktoken/core.py:289–301  ·  view source on GitHub ↗

Decodes a token into bytes. NOTE: this will decode all special tokens. Raises `KeyError` if the token is not in the vocabulary. ``` >>> enc.decode_single_token_bytes(31373) b'hello' ```

(self, token: int)

Source from the content-addressed store, hash-verified

287 return self._core_bpe.decode_bytes(tokens).decode("utf-8", errors=errors)
288
289 def decode_single_token_bytes(self, token: int) -> bytes:
290 """Decodes a token into bytes.
291
292 NOTE: this will decode all special tokens.
293
294 Raises `KeyError` if the token is not in the vocabulary.
295
296 ```
297 >>> enc.decode_single_token_bytes(31373)
298 b'hello'
299 ```
300 """
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.

Callers 4

decode_tokens_bytesMethod · 0.95
test_simpleFunction · 0.80
test_simpleFunction · 0.80

Calls

no outgoing calls

Tested by 3

test_simpleFunction · 0.64
test_simpleFunction · 0.64