Skip to content

Commit

Permalink
fix: don't skip first special token. (#1497)
Browse files Browse the repository at this point in the history
  • Loading branch information
gesanqiu authored Oct 29, 2023
1 parent 28b47d1 commit beac8dd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion vllm/transformers_utils/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ def detokenize_incrementally(
# tokenizers (bigger = more conservative).
# Subtract 1 extra to account for the generated token.
prefix_offset = max(len(output_tokens) - 6, 0)
read_offset = max(len(output_tokens) - 1, 0)
# If the first new token is a special token, we can't skip 1 extra token
if skip_special_tokens and new_token_id in tokenizer.all_special_ids:
read_offset = max(len(output_tokens), 0)
else:
read_offset = max(len(output_tokens) - 1, 0)
else:
# Put new_token_id in a list so skip_special_tokens is respected
new_tokens = tokenizer.convert_ids_to_tokens(
Expand Down

0 comments on commit beac8dd

Please sign in to comment.