Self-consistency to assess confidence
The prompt below aims to ask ChatGPT to classify the sentiment of a review. You have to estimate the confidence of ChatGPT in each class using self-consistency.
The get_response() function to communicate with ChatGPT is pre-loaded for you.
Bu egzersiz
Explainable AI in Python
kursunun bir parçasıdırEgzersiz talimatları
- For each review, append the
sentimentto theresponseslist. - Compute the confidence for each sentiment.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
prompt = """Classify the following review as positive or negative.
You should reply with either "positive" or "negative", nothing else.
Review: 'The coffee was excellent, but the service left much to be desired.'"""
responses = []
for i in range(5):
sentiment = get_response(prompt)
# Append the response to the responses list
____
# Compute the confidence for each sentiment
confidence = {
'positive': ____,
'negative': ____
}
print(confidence)