用自一致性评估置信度
下面的 prompt 旨在让 ChatGPT 对一条评论进行情感分类。您需要使用自一致性来估计 ChatGPT 在各个类别上的置信度。
用于与 ChatGPT 通信的 get_response() 函数已为您预加载。
本练习是课程的一部分
Python 可解释性 AI
练习说明
- 对每条评论,将
sentiment追加到responses列表。 - 计算每种情感的置信度。
交互式实操练习
通过完成这段示例代码来试试这个练习。
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)