mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-08-30 02:53:41 +08:00
fix stream generate
This commit is contained in:
parent
f5cd03c64d
commit
c9994f80e6
@ -300,10 +300,9 @@ def stream_generate(
|
|||||||
range(max_tokens),
|
range(max_tokens),
|
||||||
generate_step(prompt_tokens, model, **kwargs),
|
generate_step(prompt_tokens, model, **kwargs),
|
||||||
):
|
):
|
||||||
if token == tokenizer.eos_token_id:
|
|
||||||
break
|
|
||||||
detokenizer.add_token(token)
|
detokenizer.add_token(token)
|
||||||
|
if n == (max_tokens - 1) or token == tokenizer.eos_token_id:
|
||||||
|
break
|
||||||
# Yield the last segment if streaming
|
# Yield the last segment if streaming
|
||||||
yield detokenizer.last_segment, token, logits
|
yield detokenizer.last_segment, token, logits
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user