File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -81,10 +81,11 @@ def _convert_tokens_to_string_with_added_encoders(
81
81
# even when the loop body is very simple.
82
82
sub_texts = []
83
83
current_sub_text = []
84
+ all_special_tokens = set (tokenizer .all_special_tokens )
84
85
for token in output_tokens :
85
- if skip_special_tokens and token in tokenizer . all_special_tokens :
86
+ if skip_special_tokens and token in all_special_tokens :
86
87
continue
87
- if token in tokenizer .added_tokens_encoder :
88
+ if token in tokenizer .get_added_vocab () :
88
89
if current_sub_text :
89
90
sub_text = tokenizer .convert_tokens_to_string (current_sub_text )
90
91
sub_texts .append (sub_text )
@@ -129,7 +130,7 @@ def detokenize_incrementally(
129
130
# The prefix text is necessary only to defeat cleanup algorithms in
130
131
# the decode which decide to add a space or not depending on the
131
132
# surrounding ids.
132
- if not getattr ( tokenizer , "added_tokens_encoder" , {} ):
133
+ if tokenizer . is_fast or not tokenizer . get_added_vocab ( ):
133
134
prefix_text = tokenizer .convert_tokens_to_string (
134
135
output_tokens [prefix_offset :read_offset ])
135
136
new_text = tokenizer .convert_tokens_to_string (
You can’t perform that action at this time.
0 commit comments