We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 57c620b commit 6ce675eCopy full SHA for 6ce675e
src/transformers/tokenization_utils_fast.py
@@ -410,9 +410,11 @@ def convert_ids_to_tokens(
410
if isinstance(ids, int):
411
return self._tokenizer.id_to_token(ids)
412
tokens = []
413
+ # self.all_special_ids is an @property which may be slow, so only compute it once before the loop
414
+ ids_to_skip = set(self.all_special_ids) if skip_special_tokens else set()
415
for index in ids:
416
index = int(index)
- if skip_special_tokens and index in self.all_special_ids:
417
+ if index in ids_to_skip:
418
continue
419
tokens.append(self._tokenizer.id_to_token(index))
420
return tokens
0 commit comments