MCPcopy Create free account
hub / github.com/SooLab/CGFormer / convert_tokens_to_string

Method convert_tokens_to_string

bert/tokenization_utils.py:678–683  ·  view source on GitHub ↗

Converts a sequence of tokens (string) in a single string. The most simple way to do it is ' '.join(self.convert_ids_to_tokens(token_ids)) but we often want to remove sub-word tokenization artifacts at the same time.

(self, tokens: List[str])

Source from the content-addressed store, hash-verified

676 raise NotImplementedError
677
678 def convert_tokens_to_string(self, tokens: List[str]) -> str:
679 """ Converts a sequence of tokens (string) in a single string.
680 The most simple way to do it is ' '.join(self.convert_ids_to_tokens(token_ids))
681 but we often want to remove sub-word tokenization artifacts at the same time.
682 """
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

Callers 1

decodeMethod · 0.95

Calls 1

convert_ids_to_tokensMethod · 0.95

Tested by

no test coverage detected