チャット型生成AIモデルの説明

Pythonで学ぶExplainable AI

Fouad Trad

Machine Learning Engineer

チャット型生成AIモデル

  • テキスト生成に使用
  • 文脈と知識から予測

 

ユーザーが生成AIにプロンプトを送り、応答を受け取る図。

Pythonで学ぶExplainable AI

チェーン・オブ・ソート(Chain-of-thought)プロンプト

  • 推論の言語化を促す

チェーン・オブ・ソートのプロンプトが段階的解法を促し、各ステップの推論を出力する図。

Pythonで学ぶExplainable AI

チェーン・オブ・ソートの作成

prompt = """A shop starts with 20 apples. It sells 5 apples and then receives 8 more. 
How many apples does the shop have now? Show your reasoning step-by-step."""

response = get_response(prompt)
print(response)
To find out how many apples the shop has now, let's follow the transactions step-by-step:

1- The shop begins with 20 apples.
2- The shop sells 5 apples. We subtract this number from the starting quantity: 20 - 5 = 15
3- The shop receives 8 apples. We add this number to the remaining apples: 15 + 8 = 23
So, after these transactions, the shop has 23 apples.
Pythonで学ぶExplainable AI

自己一貫性

生成回答の自信度を評価

自己一貫性プロンプトは同一プロンプトを複数回送信し、それぞれ応答が得られることを示す図。

Pythonで学ぶExplainable AI

テキスト分類における自己一貫性

テキスト分類に有用

モデルがユーザーレビューを肯定/否定に分類し、複数の応答を返す自己一貫性の例。

Pythonで学ぶExplainable AI

テキスト分類における自己一貫性

テキスト分類に有用

モデルがユーザーレビューを肯定/否定に分類し、複数の応答を返す自己一貫性の例。信頼度は各カテゴリの比率で計算。

Pythonで学ぶExplainable AI

自己一貫性プロンプトの作成

prompt = """Classify the following review as positive or negative. 
You should reply with either "positive" or "negative", nothing else.
Review: 'The customer service was great, but the product itself did not meet my expectations.'"""

responses = []
for i in range(5): sentiment = get_response(review)
responses.append(sentiment.lower())
confidence = { 'positive': responses.count('positive') / len(responses), 'negative': responses.count('negative') / len(responses) }
Pythonで学ぶExplainable AI

自己一貫性プロンプトの作成

print(confidence)
{
    'positive': 0.6,
    'negative': 0.4
}
Pythonで学ぶExplainable AI

Ayo berlatih!

Pythonで学ぶExplainable AI

Preparing Video For Download...