Support stop_token_ids in sglang API (#1092)

This commit is contained in:
Liangsheng Yin
2024-08-14 17:31:39 -07:00
committed by GitHub
parent 1c2b5f5240
commit 73cf6834f2
6 changed files with 34 additions and 12 deletions

View File

@@ -235,10 +235,12 @@ class Req:
return
last_token_id = self.output_ids[-1]
if self.tokenizer is None:
matched_eos = last_token_id in self.sampling_params.stop_token_ids
else:
matched_eos = last_token_id == self.tokenizer.eos_token_id
matched_eos = last_token_id in self.sampling_params.stop_token_ids
if self.tokenizer is not None:
matched_eos |= last_token_id == self.tokenizer.eos_token_id
if matched_eos and not self.sampling_params.ignore_eos:
self.finished_reason = FINISH_MATCHED_TOKEN(matched=last_token_id)
return