Check confidence in OpenAI prediction

45 Views Asked by At

I saw that it is possible to predict a sentence based on inputs you enter, but beyond that, is it possible to see the confidence? This is my code:

def get_completion(prompt, model="gpt-3.5-turbo"):
messages = [{"role": "user", "content": prompt}]
response = openai.ChatCompletion.create(
    model=model,
    messages=messages,
    temperature=0, # this is the degree of randomness of the model's output
)
completion = response.choices[0].message["content"]
print(response.choices[0])
return completion



def get_emozione_gpt(text):
prompt = "Your are an emotion recognition tool for tweets and your task is to " \
"analize theme a give a single emotion or a list of emotions, separeted by comma that you might think that are expressed on the current tweet and you should use only the emotions from " \
"this list ['Anger', 'Anticipation', 'Disgust', 'Fear', 'Joy', 'Neutral', 'Sadness', 'Surprise', 'Trust']"

examples = """ \
Here some examples:
Input "Help, i need help" Output:"Fear"
...
(other examples)

"""
prompt = f"{prompt}\n{examples}\n Text:\"{text}\" Output: "
completion = get_completion(prompt)
return completion

in "print(response.choices[0])" i can see:

{
  "index": 0,
  "message": {
    "role": "assistant",
    "content": "Joy"
  },
  "logprobs": null,
  "finish_reason": "stop"
}

but no the confidence, so, can get the confidence or get multiple labels for text with confidence?

0

There are 0 best solutions below