[Bugfix] Remove the last EOS token unless explicitly specified (#5077)

This commit is contained in:
Junichi Sato
2024-05-29 09:15:35 +09:00
committed by GitHub
parent 5ae5ed1e60
commit dfba529b40
2 changed files with 91 additions and 0 deletions

View File

@@ -48,6 +48,11 @@ class StopChecker:
# Check if the sequence has generated the EOS token.
if ((not sampling_params.ignore_eos)
and seq.get_last_token_id() == seq.eos_token_id):
# Remove the last EOS token unless explicitly specified
# This prevents unintended exposure of the EOS token
if new_char_count and (
not sampling_params.include_stop_str_in_output):
seq.output_text = seq.output_text[:-new_char_count]
seq.status = SequenceStatus.FINISHED_STOPPED
return