Skip to content

Commit d144036

Browse files
authored
fix decode token (#2698)
1 parent 2123476 commit d144036

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

paddleformers/transformers/tokenizer_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ def decode_token(
582582
all_input_ids[prefix_offset:], skip_special_tokens=skip_special_tokens, clean_up_tokenization_spaces=False
583583
)
584584

585-
if len(new_text) > len(prefix_text) and "�" not in prefix_text and "�" not in new_text:
585+
if len(new_text) > len(prefix_text) and not new_text.endswith("�") and not new_text[:-1].endswith("�"):
586586
# utf-8 char at the end means it's a potential unfinished byte sequence
587587
# from byte fallback tokenization.
588588
# If it's in the middle, it's probably a real invalid id generated

0 commit comments

Comments
 (0)