Skip to content

Text Generate REST API schema#18

Merged
yuzisun merged 14 commits into
kserve:mainfrom
gavrissh:generate_api
Feb 6, 2024
Merged

Text Generate REST API schema#18
yuzisun merged 14 commits into
kserve:mainfrom
gavrissh:generate_api

Conversation

@gavrissh

@gavrissh gavrissh commented Dec 5, 2023

Copy link
Copy Markdown
Contributor

Propose generate rest api endpoints

/v2/models/{model_name}/versions/${MODEL_VERSION}/generate
/v2/models/{model_name}/versions/${MODEL_VERSION}/generate_stream


Screenshot 2024-01-16 at 6 43 56 PM
Screenshot 2024-01-16 at 6 44 46 PM
Screenshot 2024-01-16 at 6 46 46 PM

Reference - https://docs.nvidia.com/deeplearning/triton-inference-server/user-guide/docs/protocol/extension_generate.html#generate-extension

Propose generate rest api endpoints

Signed-off-by: Gavrish Prabhu <[email protected]>
@gavrissh gavrissh changed the title Propose generate rest api endpoints schema Text Generate REST API schema Dec 6, 2023
@gavrissh
gavrissh marked this pull request as ready for review December 6, 2023 12:27
Signed-off-by: Gavrish Prabhu <[email protected]>
Comment thread specification/protocol/generate_rest.yaml
Comment thread specification/protocol/generate_rest.yaml Outdated
Comment thread specification/protocol/generate_rest.yaml Outdated
- model_version
- done
properties:
text_output:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is concatenated text output, we might still want to see the token generated for each iteration.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Nvidia implementation, each response in returning cumulative set of tokens.

1st json
{
text_output: "Here is"
}
.
.
.
..
subsequent json response
{
text_output: "Here is the output for the prompt"
}

Should we add additional property to display token generated in current response set?

Signed-off-by: Gavrish Prabhu <[email protected]>
Signed-off-by: Gavrish Prabhu <[email protected]>
Signed-off-by: Gavrish Prabhu <[email protected]>
@gavrissh

Copy link
Copy Markdown
Contributor Author

@yuzisun Wanted to follow up, if the current state of changes are alright?

Comment thread specification/protocol/generate_rest.yaml Outdated
Comment thread specification/protocol/generate_rest.yaml Outdated
Signed-off-by: Gavrish Prabhu <[email protected]>
Signed-off-by: Gavrish Prabhu <[email protected]>
@gavrissh

gavrissh commented Jan 3, 2024

Copy link
Copy Markdown
Contributor Author

I have updated with all the recent discussed changes

Comment thread specification/protocol/generate_rest.yaml Outdated
Comment thread specification/protocol/generate_rest.yaml Outdated
Comment thread specification/protocol/generate_rest.yaml Outdated
Signed-off-by: Gavrish Prabhu <[email protected]>
Signed-off-by: Gavrish Prabhu <[email protected]>
Signed-off-by: Gavrish Prabhu <[email protected]>
@cmaddalozzo

cmaddalozzo commented Jan 11, 2024

Copy link
Copy Markdown

We should probably add the option to return log probabilities in the result. This seems to be fairly common among other APIs. This would comprise a boolean logprobs parameter in the request and a corresponding logprobs property in the response containing an array of objects with keys token and logprob.

Signed-off-by: Gavrish Prabhu <[email protected]>
@gavrissh

Copy link
Copy Markdown
Contributor Author

We should probably add the option to return log probabilities in the result. This seems to be fairly common among other APIs. This would comprise a boolean logprobs parameter in the request and a corresponding logprobs property in the response containing an array of objects with keys token and logprob.

I have updated the PR to support the above items

type: string
logprobs:
$ref: '#/components/schemas/Logprobs'
Logprobs:

@yuzisun yuzisun Jan 17, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type: string
model_version:
type: string
logprobs:

@yuzisun yuzisun Jan 17, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest change the name here, in TGI it is called details which includes the tokens, not sure if we should follow the same.
https://github.com/huggingface/text-generation-inference/blob/main/docs/openapi.json#L645

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gavrissh gavrissh Jan 17, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in OpenAI logprobs is property under choices.
Even I was not sure here. It is up for any suggestions

Current
Output -> {
text_output,
model_name,
model_version,
logprobs -> List[Token]
}

Token is followed as per TGI - https://huggingface.github.io/text-generation-inference/#/Text%20Generation%20Inference/generate_stream
Token -> {
id,
logprob,
special,
text
}

type: string
finish_reason:
type: string
logprobs:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For streaming case it is a single token.

parameters:
allOf:
- $ref: '#/components/schemas/GenerateParameters'
logprob:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be part of the GenerateParameters ?

Signed-off-by: Gavrish Prabhu <[email protected]>
type: string
description: Sequences where the API will stop generating further tokens.
logprob:
type: boolean

@yuzisun yuzisun Jan 21, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a description for this flag, also I think this should be the details flag as logprob is one of the fields on it.

type: string
details:
$ref: '#/components/schemas/StreamDetails'
Logprobs:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a description for this

Comment on lines +110 to +120
id:
type: integer
format: int32
minimum: 0
logprob:
type: number
format: float
special:
type: boolean
text:
type: string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make sure we have descriptions for these fields

type: object
additionalProperties: {}
properties:
finish_reason:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finish_reason should be an enum

properties:
finish_reason:
type: string
logprobs:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both finish_reason and logprobs should be required if details is requested.

Signed-off-by: Gavrish Prabhu <[email protected]>
Signed-off-by: Gavrish Prabhu <[email protected]>
@yuzisun

yuzisun commented Jan 25, 2024

Copy link
Copy Markdown
Member

Thanks @gavrishp !! Great job on getting this going with the initial version.

/lgtm
/approve

@oss-prow-bot

oss-prow-bot Bot commented Jan 25, 2024

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gavrishp, yuzisun

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@yuzisun
yuzisun merged commit 52528cf into kserve:main Feb 6, 2024
zevisert added a commit to open-inference/open-inference-protocol that referenced this pull request Mar 3, 2025
* Create generate_rest.yaml

Propose generate rest api endpoints

Signed-off-by: Gavrish Prabhu <[email protected]>

* Update generate_rest.yaml [x12]

Signed-off-by: Gavrish Prabhu <[email protected]>

---------

Signed-off-by: Gavrish Prabhu <[email protected]>
(cherry picked from commit kserve/open-inference-protocol@52528cf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants