-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Misc] Include matched stop string/token in responses #2976
Conversation
0700062
to
b9c7685
Compare
84c73da
to
bb6f831
Compare
@simon-mo would be good to get your thoughts on this simple addition. It would be useful for us even if it's not exposed in the openai API responses. Also not sure what the best field name is, perhaps |
c0ad972
to
ab8ba66
Compare
I think this is very simple and useful! Naming it as |
Thanks @simon-mo!
Will defer to your judgment on this! I like the simplicity of a single field but agree that more explicit could be better. |
Include matched stop string/token in responses [Cherry-picked from open upstream PR vllm-project/vllm#2976] Currently a finish_reason of "stop" is returned if any of the following are encountered: - One of the provided stop strings - One of the provided stop tokens - The EOS token It can be useful to know specifically which of these caused the sequence generation to stop, especially since by default the stop strings/tokens are omitted from the output text (and output token_ids?). This PR adds a "stop_reason" field to the CompletionOutput class which will contain the matched stop string or integer token id. It will be None otherwise, including the EOS token case. This means in particular that EOS can be inferred by (finish_reason=="stop" and stop_reason=None). I've also added to the openai server responses but not sure whether or not this should be included since it isn't part of the official API. Signed-off-by: Joe Runde <joseph.runde@ibm.com>
Include matched stop string/token in responses [Cherry-picked from open upstream PR vllm-project/vllm#2976] Currently a finish_reason of "stop" is returned if any of the following are encountered: - One of the provided stop strings - One of the provided stop tokens - The EOS token It can be useful to know specifically which of these caused the sequence generation to stop, especially since by default the stop strings/tokens are omitted from the output text (and output token_ids?). This PR adds a "stop_reason" field to the CompletionOutput class which will contain the matched stop string or integer token id. It will be None otherwise, including the EOS token case. This means in particular that EOS can be inferred by (finish_reason=="stop" and stop_reason=None). I've also added to the openai server responses but not sure whether or not this should be included since it isn't part of the official API. Signed-off-by: Joe Runde <joseph.runde@ibm.com> Signed-off-by: Joe Runde <Joseph.Runde@ibm.com>
Signed-off-by: Joe Runde <Joseph.Runde@ibm.com>
Signed-off-by: Joe Runde <Joseph.Runde@ibm.com>
2e129bd
to
560f090
Compare
Currently a finish_reason of "stop" is returned if any of the following are encountered: - One of the provided stop strings - One of the provided stop tokens - The EOS token It can be useful to know specifically which of these caused the sequence generation to stop, especially since by default the stop strings/tokens are omitted from the output text (and output token_ids?). This PR adds a "stop_reason" field to the CompletionOutput class which will contain the matched stop string or integer token id. It will be None otherwise, including the EOS token case. This means in particular that EOS can be inferred by (finish_reason=="stop" and stop_reason=None). I've also added to the openai server responses but not sure whether or not this should be included since it isn't part of the official API.
What you have is totally fine as long as it's well documented. |
Thanks @simon-mo, I just pushed a small update to add descriptions to the new |
Currently a
finish_reason
of "stop" is returned if any of the following are encountered:It can be useful to know specifically which of these caused the sequence generation to stop, especially since by default the stop strings/tokens are omitted from the output text (and output token_ids?).
This PR adds a
stop_reason
field to theCompletionOutput
class which will contain the matched stop string or integer token id. It will be None otherwise, including the EOS token case. This means in particular that EOS can be inferred ifffinish_reason=="stop" and stop_reason=None
.I've also added to the openai server responses but not sure whether or not this should be included since it isn't part of the official API.
Thanks @sahilsuneja1 for adding a test