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

[Question]: Is log probability available in llm.achat? #13544

Open
1 task done
mw19930312 opened this issue May 16, 2024 · 3 comments
Open
1 task done

[Question]: Is log probability available in llm.achat? #13544

mw19930312 opened this issue May 16, 2024 · 3 comments
Labels
question Further information is requested

Comments

@mw19930312
Copy link

Question Validation

  • I have searched both the documentation and discord for an answer.

Question

I wonder whether log prob can be retrieved through llm.achat (see https://platform.openai.com/docs/api-reference/chat#chat-create-logprobs) for log prob in OpenAI API. If so, is there an example code?

@mw19930312 mw19930312 added the question Further information is requested label May 16, 2024
Copy link

dosubot bot commented May 16, 2024

Hey @mw19930312, great to see you back! 😊 I'm on it - will get back to you with an answer shortly!

@logan-markewich
Copy link
Collaborator

@mw19930312 it already is

llm = OpenAI(..., logprobs=True, top_logprobs=20)

response = await llm.achat([ChatMessage(role='user', content='Hello!')])

print(response.logprobs)

20 is the highest openai lets you select.

Copy link

dosubot bot commented May 16, 2024

Yes, log probability can indeed be retrieved through llm.achat by setting logprobs=True and specifying top_logprobs=20 as shown in the example code provided. This configuration enables the retrieval of log probabilities for the top 20 tokens. The response.logprobs will contain the log probabilities after making a request.

Details

About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants