Skip to content

Commit

Permalink
model_run_utils: add STOP_SEQUENCE finish reason
Browse files Browse the repository at this point in the history
Signed-off-by: Daniele Trifirò <[email protected]>
  • Loading branch information
dtrifiro committed Sep 29, 2023
1 parent 7e31e6a commit bad7bc6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions caikit_nlp/toolkit/text_generation/model_run_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ def generate_text_func(
finish_reason = "EOS_TOKEN"
elif generate_ids.size(1) - 1 == max_new_tokens:
finish_reason = "MAX_TOKENS"
elif ("stopping_criteria" in gen_optional_params) and (
gen_optional_params["stopping_criteria"](
generate_ids,
None, # scores, unused by SequenceStoppingCriteria
)
):
finish_reason = "STOP_SEQUENCE"
else:
finish_reason = "OTHER"
return GeneratedTextResult(
Expand Down

0 comments on commit bad7bc6

Please sign in to comment.