Skip to main content
Convert an array of token IDs back into readable text. This is the inverse operation of cohere_tokenize().

Samples

Detokenize tokens

SELECT ai.cohere_detokenize(
    'embed-english-v3.0',
    ARRAY[5432, 8754, 389, 264, 8147, 4729]
);
Returns: 'PostgreSQL is a powerful database'

Round-trip tokenization

SELECT ai.cohere_detokenize(
    'embed-english-v3.0',
    ai.cohere_tokenize('embed-english-v3.0', 'Hello, world!')
);

Arguments

NameTypeDefaultRequiredDescription
modelTEXT-Cohere model for detokenization
tokensINT[]-Array of token IDs to convert
api_keyTEXTNULLCohere API key
api_key_nameTEXTNULLName of secret containing the API key
verboseBOOLEANFALSEEnable verbose logging

Returns

TEXT: The reconstructed text from the token IDs.