mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2025-01-12 05:17:40 +01:00
Encode the input string correctly
This commit is contained in:
parent
83584ae2d7
commit
70ff685736
@ -170,10 +170,10 @@ def generate_reply(question, tokens, inference_settings, selected_model, eos_tok
|
|||||||
|
|
||||||
cuda = "" if args.cpu else ".cuda()"
|
cuda = "" if args.cpu else ".cuda()"
|
||||||
n = None if eos_token is None else tokenizer.encode(eos_token, return_tensors='pt')[0][-1]
|
n = None if eos_token is None else tokenizer.encode(eos_token, return_tensors='pt')[0][-1]
|
||||||
|
input_ids = encode(question, tokens)
|
||||||
|
|
||||||
# Generate the entire reply at once
|
# Generate the entire reply at once
|
||||||
if args.no_stream:
|
if args.no_stream:
|
||||||
input_ids = encode(question, tokens)
|
|
||||||
output = eval(f"model.generate(input_ids, eos_token_id={n}, {preset}){cuda}")
|
output = eval(f"model.generate(input_ids, eos_token_id={n}, {preset}){cuda}")
|
||||||
reply = decode(output[0])
|
reply = decode(output[0])
|
||||||
yield formatted_outputs(reply, model_name)
|
yield formatted_outputs(reply, model_name)
|
||||||
@ -181,7 +181,6 @@ def generate_reply(question, tokens, inference_settings, selected_model, eos_tok
|
|||||||
# Generate the reply 1 token at a time
|
# Generate the reply 1 token at a time
|
||||||
else:
|
else:
|
||||||
yield formatted_outputs(question, model_name)
|
yield formatted_outputs(question, model_name)
|
||||||
input_ids = encode(question, 1)
|
|
||||||
preset = preset.replace('max_new_tokens=tokens', 'max_new_tokens=1')
|
preset = preset.replace('max_new_tokens=tokens', 'max_new_tokens=1')
|
||||||
for i in tqdm(range(tokens)):
|
for i in tqdm(range(tokens)):
|
||||||
output = eval(f"model.generate(input_ids, {preset}){cuda}")
|
output = eval(f"model.generate(input_ids, {preset}){cuda}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user