Auto-consistența pentru evaluarea încrederii
Variabila prompt de mai jos are scopul de a solicita ChatGPT să clasifice sentimentul unui review. Va trebui să estimezi încrederea ChatGPT în fiecare clasă folosind auto-consistența.
Funcția get_response() pentru a comunica cu ChatGPT este deja încărcată pentru tine.
Acest exercițiu face parte din cursul
AI Explicabil în Python
Instrucțiuni pentru exercițiu
- Pentru fiecare review, adaugă
sentimentla listaresponses. - Calculează încrederea pentru fiecare sentiment.
Exercițiu interactiv practic
Încearcă acest exercițiu completând acest cod de exemplu.
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)