Text Generation: stop if EOS token is reached (#4213)
This commit is contained in:
parent
7743b5e9de
commit
98fa73a974
1 changed files with 2 additions and 1 deletions
|
@ -353,10 +353,11 @@ def generate_reply_HF(question, original_question, seed, state, stopping_strings
|
||||||
|
|
||||||
with generate_with_streaming(**generate_params) as generator:
|
with generate_with_streaming(**generate_params) as generator:
|
||||||
for output in generator:
|
for output in generator:
|
||||||
yield get_reply_from_output_ids(output, input_ids, original_question, state, is_chat=is_chat)
|
|
||||||
if output[-1] in eos_token_ids:
|
if output[-1] in eos_token_ids:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
yield get_reply_from_output_ids(output, input_ids, original_question, state, is_chat=is_chat)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue