openai.decode

Returns the text from its tokenized representation.

This function doesn’t call the API, decoding is performed locally.

Syntax

decode(encoding, tokens, specialTokens?)

Parameters

Return value

The decoded string.

Bugs

Since OpenAI tokenizers don’t have a formal specification, the current decoder may differ from the one used by OpenAI in some cases.

Examples

openai.decode("cl100k_base", [15339, 220, 100257])
"hello <|endoftext|>"

See also

External resources