bpe decoding
(self, tokens)
| 220 | return bpe_tokens |
| 221 | |
| 222 | def decode(self, tokens): |
| 223 | """bpe decoding""" |
| 224 | decoded_tokens = [] |
| 225 | for token in tokens: |
| 226 | if self.int_token.match(str(token)): |
| 227 | decoded_tokens.append(self.decoder[int(token)]) |
| 228 | else: |
| 229 | decoded_tokens.append(str(token)) |
| 230 | text = ''.join(decoded_tokens) |
| 231 | text = bytearray([self.byte_decoder[c] for c in text]).decode('utf-8', errors=self.errors) |
| 232 | return text |
| 233 | |
| 234 | def decode_token(self, token): |
| 235 | """decode one token""" |
no test coverage detected