Fix detokenization leaving special tokens (#1044)

Signed-off-by: Antoni Baum <antoni.baum@protonmail.com>
This commit is contained in:
Antoni Baum
2023-09-14 16:37:03 -07:00
committed by GitHub
parent eda1a7cad3
commit dd54a4b026
2 changed files with 14 additions and 7 deletions
+3 -3
View File
@@ -119,9 +119,9 @@ def detokenize_incrementally(
prefix_offset = max(len(output_tokens) - 6, 0)
read_offset = max(len(output_tokens) - 1, 0)
else:
new_token = tokenizer.convert_ids_to_tokens(
new_token_id, skip_special_tokens=skip_special_tokens)
new_tokens = [new_token]
# Put new_token_id in a list so skip_special_tokens is respected
new_tokens = tokenizer.convert_ids_to_tokens(
[new_token_id], skip_special_tokens=skip_special_tokens)
output_tokens = prev_tokens + new_tokens
# The prefix text is necessary only to defeat cleanup algorithms in