mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-08-29 18:26:37 +08:00
Stop generating at eos token
This commit is contained in:
parent
95a1d50318
commit
8d496ba61a
@ -202,7 +202,11 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
tokens = []
|
tokens = []
|
||||||
for token, _ in zip(generate(prompt, model), range(args.max_tokens)):
|
for token, _ in zip(generate(prompt, model), range(args.max_tokens)):
|
||||||
tokens.append(token)
|
|
||||||
|
if token == tokenizer.eos_token_id:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
tokens.append(token)
|
||||||
|
|
||||||
if (len(tokens) % 10) == 0:
|
if (len(tokens) % 10) == 0:
|
||||||
mx.eval(tokens)
|
mx.eval(tokens)
|
||||||
|
Loading…
Reference in New Issue
Block a user