始める無料で始める

自己整合性による自信度の評価

以下の prompt は、ChatGPT にレビューの感情を分類させることを目的としています。自己整合性を用いて、各クラスに対する ChatGPT の自信度を推定してください。

ChatGPT と通信するための get_response() 関数はあらかじめ読み込まれています。

この演習はコースの一部です

Pythonで学ぶExplainable AI

コースを見る

演習の手順

  • 各レビューについて、sentimentresponses リストに追加します。
  • 各感情クラスの自信度を計算します。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

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)
コードを編集して実行