Fix: Output text is always truncated in some models (#3016)

This commit is contained in:
Sherry 2024-03-01 15:52:22 +08:00 committed by GitHub
parent 703e42ee4b
commit 54d3544784
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -980,7 +980,10 @@ class LLMEngine:
def _finalize_sequence(self, seq: Sequence,
sampling_params: SamplingParams,
stop_string: str) -> None:
if not sampling_params.include_stop_str_in_output and stop_string:
if sampling_params.include_stop_str_in_output:
return
if stop_string and seq.output_text.endswith(stop_string):
# Truncate the output text so that the stop string is
# not included in the output.
seq.output_text = seq.output_text[:-len(stop_string)]