feat: stop phi-2 output at <|endoftext|>

This commit is contained in:
Cody 2023-12-14 19:37:33 -05:00
parent 67a208b13e
commit f37ecda996

View File

@ -200,8 +200,12 @@ if __name__ == "__main__":
print("[INFO] Generating with Phi-2...", flush=True)
print(args.prompt, end="", flush=True)
end_of_response = tokenizer.encode("<|endoftext|>")[0]
tokens = []
for token, _ in zip(generate(prompt, model), range(args.max_tokens)):
if token.item() == end_of_response:
break
tokens.append(token)
if (len(tokens) % 10) == 0: