(
self, token_ids: List[int], skip_special_tokens: bool = False, clean_up_tokenization_spaces: bool = True
)
| 683 | return " ".join(self.convert_ids_to_tokens(tokens)) |
| 684 | |
| 685 | def decode( |
| 686 | self, token_ids: List[int], skip_special_tokens: bool = False, clean_up_tokenization_spaces: bool = True |
| 687 | ) -> str: |
| 688 | filtered_tokens = self.convert_ids_to_tokens(token_ids, skip_special_tokens=skip_special_tokens) |
| 689 | |
| 690 | # To avoid mixing byte-level and unicode for byte-level BPT |
| 691 | # we need to build string separatly for added tokens and byte-level tokens |
| 692 | # cf. https://github.com/huggingface/transformers/issues/1133 |
| 693 | sub_texts = [] |
| 694 | current_sub_text = [] |
| 695 | for token in filtered_tokens: |
| 696 | if skip_special_tokens and token in self.all_special_ids: |
| 697 | continue |
| 698 | if token in self.added_tokens_encoder: |
| 699 | if current_sub_text: |
| 700 | sub_texts.append(self.convert_tokens_to_string(current_sub_text)) |
| 701 | current_sub_text = [] |
| 702 | sub_texts.append(token) |
| 703 | else: |
| 704 | current_sub_text.append(token) |
| 705 | if current_sub_text: |
| 706 | sub_texts.append(self.convert_tokens_to_string(current_sub_text)) |
| 707 | text = " ".join(sub_texts) |
| 708 | |
| 709 | if clean_up_tokenization_spaces: |
| 710 | clean_text = self.clean_up_tokenization(text) |
| 711 | return clean_text |
| 712 | else: |
| 713 | return text |
| 714 | |
| 715 | def save_vocabulary(self, save_directory) -> Tuple[str]: |
| 716 | """ Save the tokenizer vocabulary to a directory. This method does *NOT* save added tokens |
nothing calls this directly
no test coverage detected