daft.functions.tokenize_decode#
tokenize_decode #
tokenize_decode(expr: Expression, tokens_path: str, *, io_config: IOConfig | None = None, pattern: str | None = None, special_tokens: str | None = None) -> Expression
Decodes each list of integer tokens into a string using a tokenizer.
Uses https://github.com/openai/tiktoken for tokenization.
Supported built-in tokenizers: cl100k_base, o200k_base, p50k_base, p50k_edit, r50k_base. Also supports loading tokens from a file in tiktoken format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr | Expression | The expression to decode. | required |
tokens_path | str | The name of a built-in tokenizer, or the path to a token file (supports downloading). | required |
io_config | optional | IOConfig to use when accessing remote storage. | None |
pattern | optional | Regex pattern to use to split strings in tokenization step. Necessary if loading from a file. | None |
special_tokens | optional | Name of the set of special tokens to use. Currently only "llama3" supported. Necessary if loading from a file. | None |
Returns:
| Name | Type | Description |
|---|---|---|
Expression | Expression | An expression with decoded strings. |
Source code in daft/functions/str.py
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 | |