Skip to content

How to use logprobs hyperparameters? #1203

Answered by mspronesti
FocusLiwen asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there. By adding the logprobs parameter you can see the log-probabilities of the most likely tokens, as well as the chosen token.
Consider the following example, which uses vLLM's OpenAI-compatible API

import openai

# Modify OpenAI's API key and API base to use vLLM's API server.
openai.api_key = "EMPTY"
openai.api_base = "http://localhost:8000/v1"

# List models API
models = openai.Model.list()
print("Models:", models)

model = models["data"][0]["id"]

# Completion API
stream = False
completion = openai.Completion.create(
    model=model,
    prompt="A robot may not injure a human being",
    echo=False,
    stream=stream,
    logprobs=5)

print("Completion results:")
if stream:
    for

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@FocusLiwen
Comment options

Answer selected by FocusLiwen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants