-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
server : add "tokens" output #10853
Merged
Merged
server : add "tokens" output #10853
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
79a8176
server : add "tokens" output
ggerganov d58f8a1
server : update readme
ggerganov 8bcfc55
server : return tokens ids only if requested
ggerganov 5bf29af
tests : improve "tokens" type check
ggerganov 99cb6be
server : remove "tokens" from the OAI endpoint
ggerganov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can also replace these 2 fields with
completion_token_output
. Then insidesend_partial_response
, we canstd::move
it tores
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P/s: we cannot
std::move
it, because insideprocess_token
,result
is still being used aftersend_partial_response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure that the
"return_tokens"
logic is necessary. Thetokens
array should be similar in JSON length to thecontent
string, though I am not sure performance wise how much slower it is to serialize an array of integers compared to a string. Anyway, I've added the flag and added tests.Note that with
"stream": true
we always return thetokens
field in the partial responses (i.e. this is not affected by the"return_tokens"
flag).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I'm thinking is that this should not degrade the performance of JSON serializing/parsing. But I'm just thinking about the bandwidth, because it seems like in most cases, we're now using double the bandwidth.
For
stream
, I don't think it's a problem because time to serialize/send/receive/parse is minor compared to the time a token is generated.But I think for now we can keep it this way. The non-OAI
/completion
is a playground anw so it's fine to expose everything. The OAI compat/v1/completions
that I'm planning to do next will be more prod-ready, thus it won't have these data in the response.Edit: I didn't notice that you implemented
return_tokens
, that's good then, let's keep it 👍There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree we can keep
/v1/completions
strongly OAI-compat (i.e. not even have extra fields liketokens
) and only have these in the non-OAI endpoints like/completions
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great to see, thank you.
I sometimes use the
/completions
API on a bandwidth-constrained network (Wireguard over a bad WAN connection) so having an option to disable tokens if I don't need them is perfect.