Decode multiple token sequences in parallel. Args: tokens: Sequence of token sequences to decode num_threads: Number of threads to use for parallel processing errors: How to handle decode errors ('replace', 'ignore', 'strict')
(
self,
tokens: Sequence[Sequence[int]],
*,
num_threads: int = 8,
errors: str = "replace",
)
| 235 | return list(e.map(encoder, text)) |
| 236 | |
| 237 | def decode_batch( |
| 238 | self, |
| 239 | tokens: Sequence[Sequence[int]], |
| 240 | *, |
| 241 | num_threads: int = 8, |
| 242 | errors: str = "replace", |
| 243 | ) -> list[str]: |
| 244 | """Decode multiple token sequences in parallel. |
| 245 | |
| 246 | Args: |
| 247 | tokens: Sequence of token sequences to decode |
| 248 | num_threads: Number of threads to use for parallel processing |
| 249 | errors: How to handle decode errors ('replace', 'ignore', 'strict') |
| 250 | |
| 251 | Returns: |
| 252 | List of decoded strings |
| 253 | """ |
| 254 | decoder = functools.partial(self.decode, errors=errors) |
| 255 | with ThreadPoolExecutor(num_threads) as e: |
| 256 | return list(e.map(decoder, tokens)) |
| 257 | |
| 258 | # ==================== |
| 259 | # Decoding methods |
nothing calls this directly
no outgoing calls
no test coverage detected