[Bugfix][Beam Search] Respect skip_special_tokens during decoding (#56211)
Signed-off-by: lxy-alexander <lxy_alexander@outlook.com> Co-authored-by: OpenAI Codex <noreply@openai.com>
This commit is contained in:
co-authored by
OpenAI Codex
parent
73d2a8cf86
commit
10e8d5614c
@@ -186,7 +186,9 @@ class BeamSearchOfflineMixin(OfflineInferenceMixin):
|
||||
best_beams = sorted_completed[:beam_width]
|
||||
|
||||
for beam in best_beams:
|
||||
beam.text = tokenizer.decode(beam.tokens)
|
||||
beam.text = tokenizer.decode(
|
||||
beam.tokens, skip_special_tokens=params.skip_special_tokens
|
||||
)
|
||||
|
||||
outputs.append(BeamSearchOutput(sequences=best_beams))
|
||||
|
||||
|
||||
@@ -197,7 +197,9 @@ class BeamSearchOnlineMixin(ABC):
|
||||
tokens = beam.tokens[tokenized_length:-1]
|
||||
else:
|
||||
tokens = beam.tokens[tokenized_length:]
|
||||
beam.text = tokenizer.decode(tokens)
|
||||
beam.text = tokenizer.decode(
|
||||
tokens, skip_special_tokens=params.skip_special_tokens
|
||||
)
|
||||
|
||||
yield RequestOutput(
|
||||
request_id=request_id,
|
||||
|
||||
@@ -659,6 +659,7 @@ class ChatCompletionRequest(OpenAIBaseModel):
|
||||
temperature=temperature,
|
||||
length_penalty=self.length_penalty,
|
||||
include_stop_str_in_output=self.include_stop_str_in_output,
|
||||
skip_special_tokens=self.skip_special_tokens,
|
||||
)
|
||||
|
||||
def extract_structured_outputs(self) -> StructuredOutputsParams | None:
|
||||
|
||||
@@ -303,6 +303,7 @@ class CompletionRequest(OpenAIBaseModel):
|
||||
temperature=temperature,
|
||||
length_penalty=self.length_penalty,
|
||||
include_stop_str_in_output=self.include_stop_str_in_output,
|
||||
skip_special_tokens=self.skip_special_tokens,
|
||||
)
|
||||
|
||||
def extract_structured_outputs(self) -> StructuredOutputsParams | None:
|
||||
|
||||
Reference in New Issue
Block a user