Skip to content
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

Support logprobs for chat completion api #2292

Closed
wants to merge 1 commit into from

Conversation

beginlner
Copy link
Contributor

@beginlner beginlner commented Dec 28, 2023

@beginlner
Copy link
Contributor Author

@WoosukKwon @zhuohan123 Could you please have a look at this PR?

@LiuXiaoxuanPKU LiuXiaoxuanPKU self-assigned this Jan 14, 2024
Copy link
Collaborator

@LiuXiaoxuanPKU LiuXiaoxuanPKU left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!! Just some minor comments.

@@ -61,6 +61,7 @@ class ChatCompletionRequest(BaseModel):
max_tokens: Optional[int] = None
stop: Optional[Union[str, List[str]]] = Field(default_factory=list)
stream: Optional[bool] = False
logprobs: Optional[int] = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you change the type to bool, which aligns with openAI spec. Also I think in the current codebase, it uses it as bool as well. Please correct me if I'm wrong.

Could you change the type definition of logprobs in CompletionRequest as well? thanks.

role = get_role()
for output in final_res.outputs:
if request.logprobs is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

if request.logprobs is False(or 0), it will still trigger this branch. Maybe a better way:

if request.logprobs:
    # do things
else:
   # do things

Please also update the same issue in other places.

@esmeetu
Copy link
Collaborator

esmeetu commented Mar 25, 2024

Close this PR as this feature has been supported in #2918. Thanks!

@esmeetu esmeetu closed this Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants